swaggest / rest

Web services with OpenAPI and JSON Schema done quick in Go
https://pkg.go.dev/github.com/swaggest/rest
MIT License
362 stars 17 forks source link

Update examples with usecase.NewIOI #25

Closed vearutop closed 3 years ago

github-actions[bot] commented 3 years ago

Unit Test Coverage

total: (statements) 81.1%

Coverage diff with base branch ```diff 148c148 < github.com/swaggest/rest/resttest/client.go assertResponseHeader 66.7% --- > github.com/swaggest/rest/resttest/client.go assertResponseHeader 71.4% ```
codecov[bot] commented 3 years ago

Codecov Report

Merging #25 (3313468) into master (1a55618) will increase coverage by 0.09%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #25      +/-   ##
==========================================
+ Coverage   73.31%   73.41%   +0.09%     
==========================================
  Files          26       26              
  Lines        1484     1482       -2     
==========================================
  Hits         1088     1088              
+ Misses        250      249       -1     
+ Partials      146      145       -1     
Flag Coverage Δ
unittests 73.41% <100.00%> (+0.09%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
response/encoder.go 63.58% <ø> (ø)
resttest/client.go 54.49% <100.00%> (+0.64%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1a55618...9731023. Read the comment docs.

github-actions[bot] commented 3 years ago

Benchmark Result

Benchmark diff with base branch ``` Using vendor name old time/op new time/op delta pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64 RequestValidator_ValidateRequestData-2 1.57µs ± 2% 1.73µs ± 3% +10.05% (p=0.016 n=5+4) pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 871ns ± 6% 969ns ± 3% +11.32% (p=0.008 n=5+5) DecoderFunc_Decode-2 2.47µs ± 5% 2.66µs ± 2% +7.90% (p=0.008 n=5+5) Decoder_Decode_json-2 28.8µs ± 3% 32.4µs ± 4% +12.75% (p=0.008 n=5+5) Decoder_Decode_queryObject-2 6.10µs ± 2% 6.88µs ± 3% +12.82% (p=0.008 n=5+5) Decoder_Decode_jsonParam-2 2.11µs ± 2% 2.46µs ± 3% +16.49% (p=0.008 n=5+5) DecoderFactory_SetDecoderFunc-2 1.94µs ± 3% 2.23µs ± 3% +14.88% (p=0.008 n=5+5) pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 13.1µs ± 2% 14.8µs ± 1% +13.26% (p=0.008 n=5+5) Middleware_control-2 4.08µs ± 2% 4.39µs ± 6% +7.78% (p=0.008 n=5+5) name old alloc/op new alloc/op delta pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64 RequestValidator_ValidateRequestData-2 2.50kB ± 0% 2.50kB ± 0% ~ (all equal) pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 448B ± 0% 440B ± 0% -1.79% (p=0.008 n=5+5) DecoderFunc_Decode-2 1.51kB ± 0% 1.51kB ± 0% ~ (all equal) Decoder_Decode_json-2 12.4kB ± 0% 12.3kB ± 0% -0.45% (p=0.008 n=5+5) Decoder_Decode_queryObject-2 2.00kB ± 0% 2.00kB ± 0% ~ (all equal) Decoder_Decode_jsonParam-2 752B ± 0% 720B ± 0% -4.26% (p=0.008 n=5+5) DecoderFactory_SetDecoderFunc-2 1.02kB ± 0% 1.02kB ± 0% ~ (all equal) pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 1.14kB ± 1% 1.12kB ± 3% ~ (p=0.151 n=5+5) Middleware_control-2 11.2kB ± 0% 11.2kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64 RequestValidator_ValidateRequestData-2 8.00 ± 0% 8.00 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 4.00 ± 0% 4.00 ± 0% ~ (all equal) DecoderFunc_Decode-2 12.0 ± 0% 12.0 ± 0% ~ (all equal) Decoder_Decode_json-2 169 ± 0% 169 ± 0% ~ (all equal) Decoder_Decode_queryObject-2 36.0 ± 0% 36.0 ± 0% ~ (all equal) Decoder_Decode_jsonParam-2 12.0 ± 0% 12.0 ± 0% ~ (all equal) DecoderFactory_SetDecoderFunc-2 16.0 ± 0% 16.0 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 11.0 ± 0% 11.0 ± 0% ~ (all equal) Middleware_control-2 9.00 ± 0% 9.00 ± 0% ~ (all equal) ```

Examples Benchmark Result

Benchmark diff with base branch ``` Using vendor name old time/op new time/op delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 34.1µs ± 4% 35.5µs ± 4% +4.20% (p=0.032 n=5+5) _directGzipHead-2 32.8µs ± 2% 35.5µs ± 1% +8.38% (p=0.008 n=5+5) _noDirectGzip-2 155µs ± 3% 170µs ± 1% +9.61% (p=0.008 n=5+5) _directGzip_decode-2 550µs ± 3% 630µs ± 3% +14.50% (p=0.008 n=5+5) _noDirectGzip_decode-2 156µs ± 2% 169µs ± 4% +8.28% (p=0.008 n=5+5) _jsonBody-2 58.6µs ± 2% 64.7µs ± 2% +10.40% (p=0.008 n=5+5) _jsonBodyValidation-2 66.3µs ± 3% 73.0µs ± 3% +10.06% (p=0.008 n=5+5) _outputHeaders-2 32.0µs ± 3% 34.3µs ± 4% +7.10% (p=0.008 n=5+5) _validation-2 62.5µs ± 3% 66.4µs ± 3% +6.25% (p=0.008 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 41.3µs ± 4% 39.3µs ± 2% -4.74% (p=0.016 n=5+5) _ok-2 43.3µs ± 3% 41.7µs ± 2% -3.85% (p=0.032 n=5+5) _invalidBody-2 60.4µs ± 1% 60.3µs ± 6% ~ (p=0.310 n=5+5) name old B:rcvd/op new B:rcvd/op delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 639 ± 0% 639 ± 0% ~ (all equal) _directGzipHead-2 183 ± 0% 183 ± 0% ~ (all equal) _noDirectGzip-2 1.04k ± 0% 1.04k ± 0% ~ (all equal) _directGzip_decode-2 639 ± 0% 639 ± 0% ~ (all equal) _noDirectGzip_decode-2 1.04k ± 0% 1.04k ± 0% ~ (all equal) _jsonBody-2 203 ± 0% 208 ± 0% +2.46% (p=0.008 n=5+5) _jsonBodyValidation-2 194 ± 0% 194 ± 0% ~ (all equal) _outputHeaders-2 155 ± 0% 155 ± 0% ~ (all equal) _validation-2 177 ± 0% 177 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 337 ± 0% 337 ± 0% ~ (all equal) _ok-2 359 ± 0% 359 ± 0% ~ (all equal) _invalidBody-2 435 ± 0% 435 ± 0% ~ (all equal) name old B:sent/op new B:sent/op delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 103 ± 0% 103 ± 0% ~ (all equal) _directGzipHead-2 104 ± 0% 104 ± 0% ~ (all equal) _noDirectGzip-2 117 ± 0% 117 ± 0% ~ (all equal) _directGzip_decode-2 116 ± 0% 116 ± 0% ~ (all equal) _noDirectGzip_decode-2 130 ± 0% 130 ± 0% ~ (all equal) _jsonBody-2 188 ± 0% 188 ± 0% ~ (all equal) _jsonBodyValidation-2 192 ± 0% 192 ± 0% ~ (all equal) _outputHeaders-2 77.0 ± 0% 77.0 ± 0% ~ (all equal) _validation-2 170 ± 0% 170 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 74.0 ± 0% 74.0 ± 0% ~ (all equal) _ok-2 74.0 ± 0% 74.0 ± 0% ~ (all equal) _invalidBody-2 137 ± 0% 137 ± 0% ~ (all equal) name old rps new rps delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 29.4k ± 4% 28.2k ± 4% -4.05% (p=0.032 n=5+5) _directGzipHead-2 30.5k ± 2% 28.1k ± 1% -7.74% (p=0.008 n=5+5) _noDirectGzip-2 6.44k ± 3% 5.87k ± 1% -8.80% (p=0.008 n=5+5) _directGzip_decode-2 1.82k ± 3% 1.59k ± 3% -12.66% (p=0.008 n=5+5) _noDirectGzip_decode-2 6.42k ± 2% 5.93k ± 4% -7.64% (p=0.008 n=5+5) _jsonBody-2 17.1k ± 2% 15.5k ± 2% -9.43% (p=0.008 n=5+5) _jsonBodyValidation-2 15.1k ± 3% 13.7k ± 3% -9.18% (p=0.008 n=5+5) _outputHeaders-2 31.2k ± 3% 29.1k ± 4% -6.62% (p=0.008 n=5+5) _validation-2 16.0k ± 3% 15.1k ± 3% -5.87% (p=0.008 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 24.2k ± 4% 25.4k ± 2% +4.94% (p=0.016 n=5+5) _ok-2 23.1k ± 3% 24.0k ± 2% +3.97% (p=0.032 n=5+5) _invalidBody-2 16.6k ± 1% 16.6k ± 5% ~ (p=0.310 n=5+5) name old alloc/op new alloc/op delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 3.82kB ± 0% 3.87kB ± 0% +1.31% (p=0.008 n=5+5) _directGzipHead-2 3.81kB ± 0% 3.86kB ± 0% +1.31% (p=0.016 n=4+5) _noDirectGzip-2 6.19kB ±16% 6.26kB ±16% ~ (p=0.690 n=5+5) _directGzip_decode-2 403kB ± 0% 402kB ± 0% ~ (p=0.690 n=5+5) _noDirectGzip_decode-2 5.16kB ± 7% 5.14kB ± 8% ~ (p=1.000 n=5+5) _jsonBody-2 11.7kB ± 0% 11.7kB ± 0% +0.24% (p=0.008 n=5+5) _jsonBodyValidation-2 18.2kB ± 0% 18.2kB ± 0% +0.19% (p=0.008 n=5+5) _outputHeaders-2 3.59kB ± 0% 3.64kB ± 0% +1.41% (p=0.016 n=4+5) _validation-2 16.1kB ± 0% 16.2kB ± 0% +0.17% (p=0.008 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 4.77kB ± 0% 4.82kB ± 0% +0.98% (p=0.008 n=5+5) _ok-2 4.68kB ± 0% 4.73kB ± 0% +1.02% (p=0.029 n=4+4) _invalidBody-2 8.69kB ± 4% 8.68kB ± 4% ~ (p=0.333 n=5+5) name old allocs/op new allocs/op delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 39.0 ± 0% 40.0 ± 0% +2.56% (p=0.008 n=5+5) _directGzipHead-2 39.0 ± 0% 40.0 ± 0% +2.56% (p=0.008 n=5+5) _noDirectGzip-2 46.8 ± 4% 47.8 ± 4% ~ (p=0.151 n=5+5) _directGzip_decode-2 496 ± 0% 498 ± 0% +0.24% (p=0.048 n=5+5) _noDirectGzip_decode-2 47.0 ± 0% 48.0 ± 0% +2.13% (p=0.008 n=5+5) _jsonBody-2 102 ± 0% 103 ± 0% +0.98% (p=0.008 n=5+5) _jsonBodyValidation-2 143 ± 0% 144 ± 0% +0.70% (p=0.008 n=5+5) _outputHeaders-2 34.0 ± 0% 35.0 ± 0% +2.94% (p=0.008 n=5+5) _validation-2 130 ± 0% 131 ± 0% +0.77% (p=0.008 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 51.0 ± 0% 52.0 ± 0% +1.96% (p=0.008 n=5+5) _ok-2 47.0 ± 0% 48.0 ± 0% +2.13% (p=0.029 n=4+4) _invalidBody-2 97.0 ± 0% 98.0 ± 0% +1.03% (p=0.029 n=4+4) ```