-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Benchmarks and Unit tests for parseRequestBody and improve it #714
Merged
Commits on Oct 2, 2023
-
Unit tests and Benchmarks for parseRequestBody function
```shell % go test -benchmem -bench=. -run=^Benchmark goos: darwin goarch: amd64 pkg: github.com/go-resty/resty/v2 cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Benchmark_parseRequestBody_string-16 2194669 550.2 ns/op 128 B/op 3 allocs/op Benchmark_parseRequestBody_byte-16 2260675 531.5 ns/op 128 B/op 3 allocs/op Benchmark_parseRequestBody_reader_with_SetContentLength-16 8393974 141.4 ns/op 16 B/op 1 allocs/op Benchmark_parseRequestBody_reader_without_SetContentLength-16 14253069 84.30 ns/op 0 B/op 0 allocs/op Benchmark_parseRequestBody_struct-16 880549 1307 ns/op 155 B/op 5 allocs/op Benchmark_parseRequestBody_struct_xml-16 424707 2886 ns/op 4762 B/op 13 allocs/op Benchmark_parseRequestBody_map-16 547629 2152 ns/op 569 B/op 15 allocs/op Benchmark_parseRequestBody_slice-16 959576 1264 ns/op 146 B/op 4 allocs/op Benchmark_parseRequestBody_FormData-16 973964 1243 ns/op 304 B/op 14 allocs/op Benchmark_parseRequestBody_MultiPart-16 98246 12320 ns/op 8746 B/op 131 allocs/op ```
Configuration menu - View commit details
-
Copy full SHA for 8c50c67 - Browse repository at this point
Copy the full SHA 8c50c67View commit details -
Benchmarks: ``` Old: Benchmark_parseRequestBody_FormData-16 954213 1266 ns/op 304 B/op 14 allocs/op New: Benchmark_parseRequestBody_FormData-16 968466 1248 ns/op 280 B/op 10 allocs/op ```
Configuration menu - View commit details
-
Copy full SHA for c7def10 - Browse repository at this point
Copy the full SHA c7def10View commit details -
Benchmarks: ``` Old: Benchmark_parseRequestBody_string-16 2199196 550.3 ns/op 128 B/op 3 allocs/op Benchmark_parseRequestBody_byte-16 2264421 532.9 ns/op 128 B/op 3 allocs/op Benchmark_parseRequestBody_reader-16 8307141 141.8 ns/op 16 B/op 1 allocs/op Benchmark_parseRequestBody_struct-16 931632 1317 ns/op 156 B/op 5 allocs/op Benchmark_parseRequestBody_struct_xml-16 409074 2921 ns/op 4765 B/op 13 allocs/op Benchmark_parseRequestBody_map-16 566750 2158 ns/op 570 B/op 15 allocs/op Benchmark_parseRequestBody_slice-16 957828 1279 ns/op 146 B/op 4 allocs/op New: Benchmark_parseRequestBody_string-16 5084247 237.0 ns/op 16 B/op 1 allocs/op Benchmark_parseRequestBody_byte-16 5298362 218.0 ns/op 16 B/op 1 allocs/op Benchmark_parseRequestBody_reader-16 8402954 141.3 ns/op 16 B/op 1 allocs/op Benchmark_parseRequestBody_struct-16 1000000 1066 ns/op 42 B/op 3 allocs/op Benchmark_parseRequestBody_struct_xml-16 452389 2575 ns/op 4648 B/op 11 allocs/op Benchmark_parseRequestBody_map-16 620391 1913 ns/op 457 B/op 13 allocs/op Benchmark_parseRequestBody_slice-16 1207551 1203 ns/op 32 B/op 2 allocs/op ```
Configuration menu - View commit details
-
Copy full SHA for 980bf46 - Browse repository at this point
Copy the full SHA 980bf46View commit details -
improve parseRequesBody and add additional benchmarks
Final benchmarks: ```shell % go test -benchmem -bench=. -run=^Benchmark goos: darwin goarch: amd64 pkg: github.com/go-resty/resty/v2 cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Benchmark_parseRequestBody_string-16 7623501 155.3 ns/op 16 B/op 1 allocs/op Benchmark_parseRequestBody_byte-16 8421992 141.6 ns/op 16 B/op 1 allocs/op Benchmark_parseRequestBody_reader_with_SetContentLength-16 17632350 67.37 ns/op 16 B/op 1 allocs/op Benchmark_parseRequestBody_reader_without_SetContentLength-16 26575016 45.34 ns/op 0 B/op 0 allocs/op Benchmark_parseRequestBody_struct-16 1243986 953.8 ns/op 40 B/op 2 allocs/op Benchmark_parseRequestBody_struct_xml-16 495250 2458 ns/op 4647 B/op 10 allocs/op Benchmark_parseRequestBody_map-16 694786 1761 ns/op 454 B/op 12 allocs/op Benchmark_parseRequestBody_slice-16 1304724 913.1 ns/op 32 B/op 2 allocs/op Benchmark_parseRequestBody_FormData-16 1000000 1128 ns/op 272 B/op 9 allocs/op Benchmark_parseRequestBody_MultiPart-16 93248 12583 ns/op 8738 B/op 130 allocs/op ```
Configuration menu - View commit details
-
Copy full SHA for 537b205 - Browse repository at this point
Copy the full SHA 537b205View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3a60dae - Browse repository at this point
Copy the full SHA 3a60daeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3408a15 - Browse repository at this point
Copy the full SHA 3408a15View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.