Skip to content
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

Decode header with canonical names #48

Merged
merged 4 commits into from
Oct 27, 2021
Merged

Decode header with canonical names #48

merged 4 commits into from
Oct 27, 2021

Conversation

vearutop
Copy link
Member

No description provided.

@github-actions
Copy link

github-actions bot commented Oct 27, 2021

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 93 6956 (+53) 5045 (+40) 470 (+3) 1441 (+10) 887 (+13) 166.9K (+1.5K)
Go (test) 39 3856 (+48) 2955 (+40) 124 777 (+8) 107 107.9K (+1.4K)

@github-actions
Copy link

API Changes

# summary
Inferred base version: v0.2.14
Suggested version: v0.2.15

@github-actions
Copy link

github-actions bot commented Oct 27, 2021

Benchmark Result

Benchmark diff with base branch
name                                    old time/op    new time/op    delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2    1.56µs ± 5%    1.50µs ± 4%   ~     (p=0.095 n=5+5)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                           789ns ± 5%     780ns ± 2%   ~     (p=0.222 n=5+5)
DecoderFunc_Decode-2                      2.32µs ± 8%    2.32µs ± 4%   ~     (p=1.000 n=5+5)
Decoder_Decode_json-2                     27.3µs ± 3%    28.5µs ±10%   ~     (p=0.222 n=5+5)
Decoder_Decode_queryObject-2              5.74µs ± 8%    5.52µs ± 5%   ~     (p=0.310 n=5+5)
Decoder_Decode_jsonParam-2                2.03µs ± 3%    2.06µs ± 3%   ~     (p=0.310 n=5+5)
DecoderFactory_SetDecoderFunc-2           1.86µs ± 1%    1.95µs ± 6%   ~     (p=0.056 n=5+5)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                              12.2µs ± 5%    13.0µs ±11%   ~     (p=0.056 n=5+5)
Middleware_control-2                      4.08µs ± 4%    3.97µs ± 2%   ~     (p=0.095 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.46kB ± 0%    2.46kB ± 0%   ~     (all equal)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                            440B ± 0%      440B ± 0%   ~     (all equal)
DecoderFunc_Decode-2                      1.51kB ± 0%    1.51kB ± 0%   ~     (all equal)
Decoder_Decode_json-2                     12.3kB ± 0%    12.3kB ± 0%   ~     (all equal)
Decoder_Decode_queryObject-2              2.00kB ± 0%    2.00kB ± 0%   ~     (all equal)
Decoder_Decode_jsonParam-2                  736B ± 0%      736B ± 0%   ~     (all equal)
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.16kB ± 3%    1.20kB ± 5%   ~     (p=0.056 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                        172 ± 0%       172 ± 0%   ~     (all equal)
Decoder_Decode_queryObject-2                36.0 ± 0%      36.0 ± 0%   ~     (all equal)
Decoder_Decode_jsonParam-2                  13.0 ± 0%      13.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)
Benchmark result
name                                    time/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2  1.50µs ± 4%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                         780ns ± 2%
DecoderFunc_Decode-2                    2.32µs ± 4%
Decoder_Decode_json-2                   28.5µs ±10%
Decoder_Decode_queryObject-2            5.52µs ± 5%
Decoder_Decode_jsonParam-2              2.06µs ± 3%
DecoderFactory_SetDecoderFunc-2         1.95µs ± 6%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                            13.0µs ±11%
Middleware_control-2                    3.97µs ± 2%

name                                    alloc/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2  2.46kB ± 0%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                          440B ± 0%
DecoderFunc_Decode-2                    1.51kB ± 0%
Decoder_Decode_json-2                   12.3kB ± 0%
Decoder_Decode_queryObject-2            2.00kB ± 0%
Decoder_Decode_jsonParam-2                736B ± 0%
DecoderFactory_SetDecoderFunc-2         1.02kB ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                            1.20kB ± 5%
Middleware_control-2                    11.2kB ± 0%

name                                    allocs/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2    8.00 ± 0%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                          4.00 ± 0%
DecoderFunc_Decode-2                      12.0 ± 0%
Decoder_Decode_json-2                      172 ± 0%
Decoder_Decode_queryObject-2              36.0 ± 0%
Decoder_Decode_jsonParam-2                13.0 ± 0%
DecoderFactory_SetDecoderFunc-2           16.0 ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                              11.0 ± 0%
Middleware_control-2                      9.00 ± 0%

@github-actions
Copy link

github-actions bot commented Oct 27, 2021

Examples Benchmark Result

Benchmark diff with base branch
name                    old time/op    new time/op    delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2             30.1µs ±12%    29.9µs ± 7%    ~     (p=1.000 n=5+5)
_directGzipHead-2         29.4µs ± 3%    29.3µs ± 5%    ~     (p=0.841 n=5+5)
_noDirectGzip-2            159µs ± 4%     160µs ± 4%    ~     (p=0.841 n=5+5)
_directGzip_decode-2       583µs ± 2%     567µs ± 2%  -2.71%  (p=0.032 n=5+5)
_noDirectGzip_decode-2     161µs ± 2%     156µs ± 3%  -3.19%  (p=0.016 n=5+5)
_jsonBody-2               59.9µs ± 1%    59.3µs ± 3%    ~     (p=0.841 n=5+5)
_jsonBodyValidation-2     62.5µs ± 3%    62.2µs ± 2%    ~     (p=1.000 n=5+5)
_outputHeaders-2          28.9µs ± 2%    29.3µs ± 3%    ~     (p=0.310 n=5+5)
_validation-2             57.9µs ± 2%    58.1µs ± 1%    ~     (p=0.413 n=5+4)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2            33.5µs ±10%    33.8µs ±11%    ~     (p=0.690 n=5+5)
_ok-2                     34.8µs ± 2%    34.7µs ± 2%    ~     (p=0.548 n=5+5)
_invalidBody-2            50.5µs ± 3%    50.9µs ± 3%    ~     (p=0.548 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                  208 ± 0%       208 ± 0%    ~     (all equal)
_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%    ~     (p=0.444 n=5+5)
_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              33.3k ±11%     33.5k ± 7%    ~     (p=1.000 n=5+5)
_directGzipHead-2          34.1k ± 3%     34.2k ± 5%    ~     (p=0.841 n=5+5)
_noDirectGzip-2            6.29k ± 4%     6.25k ± 5%    ~     (p=0.841 n=5+5)
_directGzip_decode-2       1.72k ± 2%     1.76k ± 2%  +2.78%  (p=0.032 n=5+5)
_noDirectGzip_decode-2     6.22k ± 2%     6.42k ± 3%  +3.31%  (p=0.016 n=5+5)
_jsonBody-2                16.7k ± 1%     16.9k ± 3%    ~     (p=0.841 n=5+5)
_jsonBodyValidation-2      16.0k ± 3%     16.1k ± 2%    ~     (p=1.000 n=5+5)
_outputHeaders-2           34.7k ± 2%     34.1k ± 3%    ~     (p=0.310 n=5+5)
_validation-2              17.3k ± 2%     17.2k ± 1%    ~     (p=0.413 n=5+4)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2             29.9k ± 9%     29.6k ±10%    ~     (p=0.690 n=5+5)
_ok-2                      28.7k ± 2%     28.9k ± 2%    ~     (p=0.548 n=5+5)
_invalidBody-2             19.8k ± 3%     19.7k ± 3%    ~     (p=0.548 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.86kB ± 0%    3.86kB ± 0%    ~     (p=0.127 n=5+5)
_directGzipHead-2         3.86kB ± 0%    3.86kB ± 0%    ~     (p=0.381 n=5+5)
_noDirectGzip-2           6.29kB ±23%    6.29kB ±21%    ~     (p=1.000 n=5+5)
_directGzip_decode-2       402kB ± 0%     403kB ± 0%    ~     (p=0.095 n=5+5)
_noDirectGzip_decode-2    5.24kB ±12%    5.22kB ± 9%    ~     (p=1.000 n=5+5)
_jsonBody-2               13.2kB ± 0%    13.2kB ± 0%    ~     (p=0.540 n=5+5)
_jsonBodyValidation-2     18.2kB ± 0%    18.2kB ± 0%    ~     (p=0.190 n=5+5)
_outputHeaders-2          3.64kB ± 0%    3.64kB ± 0%    ~     (p=0.913 n=5+5)
_validation-2             16.2kB ± 0%    16.2kB ± 0%    ~     (p=0.952 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2            4.81kB ± 0%    4.82kB ± 0%    ~     (p=0.881 n=5+5)
_ok-2                     4.72kB ± 0%    4.72kB ± 0%    ~     (p=0.486 n=4+4)
_invalidBody-2            8.63kB ± 0%    8.60kB ± 0%  -0.29%  (p=0.029 n=4+4)

name                    old allocs/op  new allocs/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2               40.0 ± 0%      40.0 ± 0%    ~     (all equal)
_directGzipHead-2           40.0 ± 0%      40.0 ± 0%    ~     (all equal)
_noDirectGzip-2             47.8 ± 4%      47.8 ± 4%    ~     (p=1.000 n=5+5)
_directGzip_decode-2         497 ± 0%       497 ± 0%    ~     (all equal)
_noDirectGzip_decode-2      48.0 ± 0%      48.0 ± 0%    ~     (all equal)
_jsonBody-2                  124 ± 0%       124 ± 0%    ~     (all equal)
_jsonBodyValidation-2        144 ± 0%       144 ± 0%    ~     (all equal)
_outputHeaders-2            35.0 ± 0%      35.0 ± 0%    ~     (all equal)
_validation-2                131 ± 0%       131 ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2              52.0 ± 0%      52.0 ± 0%    ~     (all equal)
_ok-2                       48.0 ± 0%      48.0 ± 0%    ~     (all equal)
_invalidBody-2              99.0 ± 0%      98.0 ± 0%  -1.01%  (p=0.029 n=4+4)

@github-actions
Copy link

Unit Test Coverage

total: (statements) 82.4%

Coverage diff with base branch
94c94
< github.com/swaggest/rest/request/decoder.go	formDataToURLValues	77.8%
---
> github.com/swaggest/rest/request/decoder.go	formDataToURLValues	66.7%
100c100,101
< github.com/swaggest/rest/request/factory.go	MakeDecoder	96.0%
---
> github.com/swaggest/rest/request/factory.go	MakeDecoder	96.2%
> github.com/swaggest/rest/request/factory.go	prepareCustomMapping	100.0%
103c104
< github.com/swaggest/rest/request/factory.go	makeCustomMappingDecoder	91.7%
---
> github.com/swaggest/rest/request/factory.go	makeCustomMappingDecoder	93.3%
183c184
< total:	(statements)	82.2%
---
> total:	(statements)	82.4%

@codecov
Copy link

codecov bot commented Oct 27, 2021

Codecov Report

Merging #48 (9857d39) into master (c6940ee) will decrease coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #48      +/-   ##
==========================================
- Coverage   74.39%   74.27%   -0.12%     
==========================================
  Files          26       26              
  Lines        1578     1559      -19     
==========================================
- Hits         1174     1158      -16     
+ Misses        252      251       -1     
+ Partials      152      150       -2     
Flag Coverage Δ
unittests 74.27% <100.00%> (-0.12%) ⬇️

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

Impacted Files Coverage Δ
nethttp/handler.go 84.88% <ø> (ø)
request/factory.go 84.84% <100.00%> (+2.49%) ⬆️
request/decoder.go 71.42% <0.00%> (-5.72%) ⬇️

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 c6940ee...9857d39. Read the comment docs.

@vearutop vearutop merged commit 948ff5d into master Oct 27, 2021
@vearutop vearutop deleted the canonical-headers branch October 27, 2021 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant