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

Add http.Hijacker to gzip middleware, add usecase middleware example #124

Merged
merged 3 commits into from
Jan 19, 2023

Conversation

vearutop
Copy link
Member

@vearutop vearutop commented Jan 19, 2023

Fixes #107.

@github-actions
Copy link

github-actions bot commented Jan 19, 2023

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 105 7305 (+55) 5302 (+43) 488 (+1) 1515 (+11) 880 (+4) 176.4K (+1.3K)
Go (test) 47 5096 (+31) 3899 (+22) 185 1012 (+9) 179 (+1) 142.1K (+834B)

@github-actions
Copy link

github-actions bot commented Jan 19, 2023

Unit Test Coverage

total: (statements) 83.4%
changed lines: (statements) 88.9%, coverage is less than 90.0%, consider testing the changes more thoroughly

Coverage of changed lines
File Function Coverage
Total 88.9%
response/gzip/middleware.go 88.9%
response/gzip/middleware.go:27 Middleware 100.0%
response/gzip/middleware.go:81 maybeGzipResponseWriter 100.0%
response/gzip/middleware.go:126 Hijack 0.0%
Coverage diff with base branch
File Function Base Coverage Current Coverage
Total 83.4% 83.4% (0.0%)
github.com/swaggest/rest/response/gzip/middleware.go Hijack no function 0.0%

@github-actions
Copy link

Go API Changes

# summary
Inferred base version: v0.2.37
Suggested version: v0.2.38

@codecov
Copy link

codecov bot commented Jan 19, 2023

Codecov Report

Merging #124 (2efd9e3) into master (ee2f875) will increase coverage by 0.05%.
The diff coverage is 90.00%.

@@            Coverage Diff             @@
##           master     #124      +/-   ##
==========================================
+ Coverage   77.54%   77.59%   +0.05%     
==========================================
  Files          28       28              
  Lines        1483     1491       +8     
==========================================
+ Hits         1150     1157       +7     
- Misses        216      217       +1     
  Partials      117      117              
Flag Coverage Δ
unittests 77.59% <90.00%> (+0.05%) ⬆️

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

Impacted Files Coverage Δ
response/gzip/middleware.go 78.94% <90.00%> (+0.78%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link

github-actions bot commented Jan 19, 2023

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.36µs ± 1%    1.35µs ± 1%    ~     (p=0.792 n=5+6)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                           694ns ± 2%     685ns ± 0%  -1.25%  (p=0.008 n=5+5)
DecoderFunc_Decode-2                      2.01µs ± 0%    1.98µs ± 1%  -1.46%  (p=0.008 n=5+5)
Decoder_Decode_json-2                     22.9µs ± 0%    22.8µs ± 0%    ~     (p=0.699 n=6+6)
Decoder_Decode_queryObject-2              4.99µs ± 0%    4.98µs ± 0%    ~     (p=0.307 n=6+5)
Decoder_Decode_jsonParam-2                1.95µs ± 1%    1.95µs ± 0%    ~     (p=0.684 n=6+5)
DecoderFactory_SetDecoderFunc-2           1.70µs ± 4%    1.67µs ± 0%  -1.36%  (p=0.004 n=5+6)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                              11.4µs ± 0%    11.8µs ± 3%  +3.58%  (p=0.002 n=6+6)
Middleware_control-2                      3.21µs ± 2%    3.25µs ± 1%    ~     (p=0.151 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.2kB ± 0%    12.2kB ± 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.15kB ± 0%    1.18kB ± 3%  +2.83%  (p=0.013 n=5+6)
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                        177 ± 0%       177 ± 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.35µs ± 1%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                         685ns ± 0%
DecoderFunc_Decode-2                    1.98µs ± 1%
Decoder_Decode_json-2                   22.8µs ± 0%
Decoder_Decode_queryObject-2            4.98µs ± 0%
Decoder_Decode_jsonParam-2              1.95µs ± 0%
DecoderFactory_SetDecoderFunc-2         1.67µs ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                            11.8µs ± 3%
Middleware_control-2                    3.25µs ± 1%

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.2kB ± 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.18kB ± 3%
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                      177 ± 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 Jan 19, 2023

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                27.6µs ± 2%    28.8µs ±11%     ~     (p=0.095 n=5+5)
_directGzipHead-2            27.3µs ± 3%    27.6µs ± 5%     ~     (p=0.690 n=5+5)
_noDirectGzip-2               149µs ± 2%     151µs ± 2%     ~     (p=0.222 n=5+5)
_directGzip_decode-2          542µs ± 6%     568µs ± 3%     ~     (p=0.151 n=5+5)
_noDirectGzip_decode-2        147µs ± 1%     152µs ± 3%   +3.80%  (p=0.008 n=5+5)
_jsonBody-2                  51.3µs ± 2%    53.4µs ± 1%   +4.00%  (p=0.008 n=5+5)
_jsonBodyValidation-2        58.5µs ± 3%    59.9µs ± 2%     ~     (p=0.095 n=5+5)
_outputHeaders-2             26.7µs ± 2%    26.7µs ± 3%     ~     (p=1.000 n=5+5)
_requestResponseMapping-2    50.3µs ± 1%    52.4µs ± 1%   +4.34%  (p=0.008 n=5+5)
_validation-2                53.1µs ± 3%    54.8µs ± 2%   +3.32%  (p=0.032 n=5+5)
_noValidation-2              39.2µs ± 3%    41.4µs ± 3%   +5.38%  (p=0.032 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                28.0µs ± 1%    31.1µs ±12%  +11.13%  (p=0.016 n=4+5)
_directGzipHead-2            28.0µs ± 4%    29.6µs ± 5%   +5.59%  (p=0.016 n=5+5)
_noDirectGzip-2               148µs ± 2%     154µs ± 1%   +4.18%  (p=0.008 n=5+5)
_directGzip_decode-2          528µs ± 3%     559µs ± 2%   +5.98%  (p=0.008 n=5+5)
_noDirectGzip_decode-2        149µs ± 1%     152µs ± 1%   +1.81%  (p=0.008 n=5+5)
_htmlResponse-2              44.5µs ± 2%    45.4µs ± 2%   +2.01%  (p=0.032 n=5+5)
_jsonBodyManual-2            31.9µs ± 3%    33.4µs ± 3%   +4.81%  (p=0.008 n=5+5)
_jsonBody-2                  46.1µs ± 1%    48.1µs ± 1%   +4.47%  (p=0.008 n=5+5)
_jsonBodyValidation-2        59.1µs ± 4%    62.5µs ± 2%   +5.70%  (p=0.008 n=5+5)
_outputHeaders-2             27.6µs ± 3%    28.7µs ± 2%   +4.15%  (p=0.016 n=5+5)
_requestResponseMapping-2    50.5µs ± 3%    52.2µs ± 4%     ~     (p=0.151 n=5+5)
_validation-2                53.3µs ± 3%    56.9µs ± 2%   +6.73%  (p=0.008 n=5+5)
_noValidation-2              40.4µs ± 2%    41.8µs ± 4%   +3.53%  (p=0.032 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2               32.5µs ±14%    32.6µs ± 1%     ~     (p=0.190 n=5+4)
_ok-2                        31.8µs ± 6%    33.1µs ± 2%     ~     (p=0.095 n=5+5)
_invalidBody-2               44.9µs ± 4%    47.1µs ± 1%   +4.95%  (p=0.016 n=5+5)

name                       old 50%:ms     new 50%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2                  1.32 ± 4%      1.34 ± 6%     ~     (p=0.841 n=5+5)
_directGzipHead-2              1.28 ± 7%      1.31 ± 4%     ~     (p=0.841 n=5+5)
_noDirectGzip-2                7.11 ± 4%      7.39 ± 7%     ~     (p=0.222 n=5+5)
_directGzip_decode-2           20.6 ±11%      22.3 ± 4%     ~     (p=0.095 n=5+5)
_noDirectGzip_decode-2         7.18 ± 5%      7.62 ± 5%     ~     (p=0.056 n=5+5)
_jsonBody-2                    2.24 ± 4%      2.39 ± 4%   +6.64%  (p=0.032 n=5+5)
_jsonBodyValidation-2          2.55 ± 5%      2.67 ± 3%   +4.76%  (p=0.032 n=5+5)
_outputHeaders-2               1.26 ± 3%      1.27 ± 5%     ~     (p=1.000 n=5+5)
_requestResponseMapping-2      2.19 ± 7%      2.23 ± 7%     ~     (p=0.548 n=5+5)
_validation-2                  2.31 ± 1%      2.49 ± 7%   +7.76%  (p=0.032 n=5+5)
_noValidation-2                1.77 ± 2%      1.91 ± 8%     ~     (p=0.056 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                  1.36 ± 6%      1.41 ± 9%     ~     (p=0.548 n=5+5)
_directGzipHead-2              1.31 ± 5%      1.41 ± 8%   +7.72%  (p=0.032 n=5+5)
_noDirectGzip-2                7.20 ± 8%      7.33 ± 5%     ~     (p=0.841 n=5+5)
_directGzip_decode-2           20.9 ± 5%      22.1 ±10%     ~     (p=0.095 n=5+5)
_noDirectGzip_decode-2         7.05 ± 3%      7.42 ± 5%   +5.22%  (p=0.016 n=5+5)
_htmlResponse-2                2.06 ± 7%      2.07 ± 3%     ~     (p=1.000 n=5+5)
_jsonBodyManual-2              1.51 ± 4%      1.56 ± 7%     ~     (p=0.421 n=5+5)
_jsonBody-2                    2.09 ± 5%      2.10 ± 1%     ~     (p=0.683 n=5+5)
_jsonBodyValidation-2          2.64 ± 4%      2.67 ± 5%     ~     (p=0.548 n=5+5)
_outputHeaders-2               1.28 ± 6%      1.35 ± 8%     ~     (p=0.254 n=5+5)
_requestResponseMapping-2      2.11 ± 5%      2.20 ± 7%     ~     (p=0.222 n=5+5)
_validation-2                  2.29 ± 4%      2.44 ± 5%   +6.67%  (p=0.032 n=5+5)
_noValidation-2                1.86 ± 6%      1.88 ± 5%     ~     (p=0.548 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2                 1.53 ± 8%      1.59 ± 3%     ~     (p=0.222 n=5+5)
_ok-2                          1.53 ± 6%      1.53 ± 2%     ~     (p=0.937 n=5+5)
_invalidBody-2                 1.97 ± 6%      2.02 ± 4%     ~     (p=0.421 n=5+5)

name                       old 90%:ms     new 90%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2                  2.35 ± 3%      2.43 ± 7%     ~     (p=0.206 n=5+5)
_directGzipHead-2              2.26 ± 3%      2.37 ± 8%     ~     (p=0.151 n=5+5)
_noDirectGzip-2                12.5 ± 4%      12.9 ± 5%     ~     (p=0.222 n=5+5)
_directGzip_decode-2           46.7 ± 5%      48.4 ± 3%     ~     (p=0.421 n=5+5)
_noDirectGzip_decode-2         12.5 ± 4%      13.0 ± 2%     ~     (p=0.056 n=5+5)
_jsonBody-2                    4.78 ± 4%      4.81 ± 7%     ~     (p=1.000 n=5+5)
_jsonBodyValidation-2          5.21 ± 2%      5.54 ± 7%   +6.26%  (p=0.032 n=5+5)
_outputHeaders-2               2.23 ± 3%      2.22 ± 7%     ~     (p=0.690 n=5+5)
_requestResponseMapping-2      4.55 ± 4%      4.92 ± 2%   +8.18%  (p=0.008 n=5+5)
_validation-2                  4.97 ± 5%      5.22 ± 5%     ~     (p=0.095 n=5+5)
_noValidation-2                3.54 ± 7%      3.71 ± 6%     ~     (p=0.222 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                  2.41 ± 9%      2.53 ± 6%     ~     (p=0.095 n=5+5)
_directGzipHead-2              2.39 ± 8%      2.46 ± 8%     ~     (p=0.421 n=5+5)
_noDirectGzip-2                12.5 ± 2%      13.1 ± 3%   +4.50%  (p=0.024 n=5+5)
_directGzip_decode-2           44.3 ± 6%      48.2 ± 5%   +8.71%  (p=0.016 n=5+5)
_noDirectGzip_decode-2         12.8 ± 4%      13.0 ± 2%     ~     (p=0.460 n=5+5)
_htmlResponse-2                4.06 ± 6%      4.00 ± 4%     ~     (p=0.516 n=5+5)
_jsonBodyManual-2              2.77 ± 7%      2.85 ± 3%     ~     (p=0.421 n=5+5)
_jsonBody-2                    4.26 ± 4%      4.34 ± 2%     ~     (p=0.222 n=5+5)
_jsonBodyValidation-2          5.44 ± 4%      5.77 ± 4%   +5.93%  (p=0.032 n=5+5)
_outputHeaders-2               2.24 ± 5%      2.39 ± 6%     ~     (p=0.111 n=5+5)
_requestResponseMapping-2      4.82 ± 3%      4.99 ± 8%     ~     (p=0.690 n=5+5)
_validation-2                  5.02 ± 6%      5.26 ± 3%     ~     (p=0.151 n=5+5)
_noValidation-2                3.58 ± 3%      3.67 ± 3%     ~     (p=0.222 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2                 2.76 ± 6%      2.84 ± 7%     ~     (p=0.310 n=5+5)
_ok-2                          2.64 ± 5%      2.89 ± 8%   +9.70%  (p=0.032 n=5+5)
_invalidBody-2                 4.10 ± 9%      4.38 ± 6%   +6.90%  (p=0.032 n=5+5)

name                       old 99%:ms     new 99%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2                  3.91 ± 8%      4.08 ± 6%     ~     (p=0.286 n=5+4)
_directGzipHead-2              4.38 ±15%      4.15 ± 6%     ~     (p=0.690 n=5+5)
_noDirectGzip-2                20.2 ± 5%      19.3 ± 4%   -4.19%  (p=0.032 n=5+5)
_directGzip_decode-2           79.2 ±13%      81.2 ±15%     ~     (p=0.841 n=5+5)
_noDirectGzip_decode-2         18.9 ± 3%      19.8 ± 7%     ~     (p=0.548 n=5+5)
_jsonBody-2                    7.88 ±10%      8.63 ±16%     ~     (p=0.222 n=5+5)
_jsonBodyValidation-2          9.49 ±22%      8.39 ±14%     ~     (p=0.222 n=5+5)
_outputHeaders-2               4.48 ± 8%      4.46 ±10%     ~     (p=1.000 n=5+5)
_requestResponseMapping-2      8.24 ± 5%      7.88 ±10%     ~     (p=0.548 n=5+5)
_validation-2                  7.61 ± 5%      7.76 ± 4%     ~     (p=0.421 n=5+5)
_noValidation-2                6.62 ±11%      6.87 ±10%     ~     (p=0.548 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                  4.12 ± 1%      6.30 ±67%  +52.64%  (p=0.016 n=4+5)
_directGzipHead-2              4.21 ±11%      4.52 ±10%     ~     (p=0.095 n=5+5)
_noDirectGzip-2                18.6 ± 4%      20.1 ± 4%   +8.08%  (p=0.016 n=5+5)
_directGzip_decode-2           73.9 ± 5%      77.2 ± 4%     ~     (p=0.151 n=5+5)
_noDirectGzip_decode-2         19.8 ± 5%      19.9 ± 7%     ~     (p=0.841 n=5+5)
_htmlResponse-2                6.88 ±10%      7.22 ± 9%     ~     (p=0.310 n=5+5)
_jsonBodyManual-2              5.10 ±23%      5.23 ± 7%     ~     (p=0.222 n=5+5)
_jsonBody-2                    6.92 ±11%      7.30 ± 5%     ~     (p=0.151 n=5+5)
_jsonBodyValidation-2          8.72 ±13%      9.13 ±17%     ~     (p=0.548 n=5+5)
_outputHeaders-2               4.85 ± 8%      5.21 ± 8%     ~     (p=0.151 n=5+5)
_requestResponseMapping-2      7.94 ±17%      8.51 ±35%     ~     (p=1.000 n=5+5)
_validation-2                  7.83 ±10%      8.99 ±14%     ~     (p=0.095 n=5+5)
_noValidation-2                6.94 ± 4%      6.93 ±20%     ~     (p=0.310 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2                 4.22 ± 5%      4.39 ± 2%     ~     (p=0.200 n=4+4)
_ok-2                          4.55 ±12%      4.61 ± 4%     ~     (p=0.548 n=5+5)
_invalidBody-2                 7.59 ±11%      8.15 ±14%     ~     (p=0.151 n=5+5)

name                       old 99.9%:ms   new 99.9%:ms   delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2                  7.80 ±70%     10.00 ±50%     ~     (p=0.421 n=5+5)
_directGzipHead-2              9.18 ±43%      7.35 ±21%     ~     (p=0.421 n=5+5)
_noDirectGzip-2                26.0 ±20%      22.6 ±10%     ~     (p=0.222 n=5+5)
_directGzip_decode-2            107 ± 9%       107 ±19%     ~     (p=0.841 n=5+5)
_noDirectGzip_decode-2         23.3 ±14%      23.2 ± 7%     ~     (p=0.730 n=5+4)
_jsonBody-2                    14.8 ±14%      14.1 ±25%     ~     (p=0.421 n=5+5)
_jsonBodyValidation-2          14.6 ±36%      11.1 ±13%     ~     (p=0.151 n=5+5)
_outputHeaders-2               10.6 ± 6%       8.9 ±49%     ~     (p=0.310 n=5+5)
_requestResponseMapping-2      15.4 ±11%      15.1 ±36%     ~     (p=0.690 n=5+5)
_validation-2                  12.2 ±22%      13.2 ±25%     ~     (p=0.690 n=5+5)
_noValidation-2                10.4 ±22%      11.9 ±17%     ~     (p=0.222 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                  9.43 ±82%     11.97 ±45%     ~     (p=0.222 n=5+5)
_directGzipHead-2              8.90 ±40%      8.99 ±27%     ~     (p=1.000 n=5+5)
_noDirectGzip-2                21.5 ± 5%      23.0 ±10%     ~     (p=0.056 n=5+5)
_directGzip_decode-2           96.6 ±11%     104.0 ±20%     ~     (p=0.690 n=5+5)
_noDirectGzip_decode-2         24.7 ±32%      23.1 ± 5%     ~     (p=1.000 n=5+5)
_htmlResponse-2                11.6 ±31%      12.2 ±46%     ~     (p=1.000 n=5+5)
_jsonBodyManual-2              9.25 ±33%     10.89 ±30%     ~     (p=0.310 n=5+5)
_jsonBody-2                    9.17 ±10%     12.65 ±34%  +37.97%  (p=0.032 n=4+5)
_jsonBodyValidation-2          14.0 ±23%      13.2 ±23%     ~     (p=0.690 n=5+5)
_outputHeaders-2               8.83 ±20%     10.53 ±10%     ~     (p=0.056 n=5+5)
_requestResponseMapping-2      13.3 ±14%      14.5 ±46%     ~     (p=0.690 n=5+5)
_validation-2                  13.4 ±28%      15.3 ±71%     ~     (p=1.000 n=5+5)
_noValidation-2                11.2 ±39%      10.8 ±21%     ~     (p=0.841 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2                 8.49 ±75%     8.69 ±101%     ~     (p=0.841 n=5+5)
_ok-2                          9.03 ±59%      8.84 ±40%     ~     (p=1.000 n=5+5)
_invalidBody-2                 10.5 ±21%      12.1 ±31%     ~     (p=0.421 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)
_requestResponseMapping-2      94.0 ± 0%      94.0 ± 0%     ~     (all equal)
_validation-2                   177 ± 0%       177 ± 0%     ~     (all equal)
_noValidation-2                 177 ± 0%       177 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                   653 ± 0%       653 ± 0%     ~     (all equal)
_directGzipHead-2               197 ± 0%       197 ± 0%     ~     (all equal)
_noDirectGzip-2               1.06k ± 0%     1.06k ± 0%     ~     (all equal)
_directGzip_decode-2            653 ± 0%       653 ± 0%     ~     (all equal)
_noDirectGzip_decode-2        1.06k ± 0%     1.06k ± 0%     ~     (all equal)
_htmlResponse-2                 370 ± 0%       370 ± 0%     ~     (all equal)
_jsonBodyManual-2               222 ± 0%       222 ± 0%     ~     (all equal)
_jsonBody-2                     222 ± 0%       222 ± 0%     ~     (all equal)
_jsonBodyValidation-2           208 ± 0%       208 ± 0%     ~     (all equal)
_outputHeaders-2                169 ± 0%       169 ± 0%     ~     (all equal)
_requestResponseMapping-2       108 ± 0%       108 ± 0%     ~     (all equal)
_validation-2                   191 ± 0%       191 ± 0%     ~     (all equal)
_noValidation-2                 191 ± 0%       191 ± 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)
_requestResponseMapping-2       169 ± 0%       169 ± 0%     ~     (all equal)
_validation-2                   170 ± 0%       170 ± 0%     ~     (all equal)
_noValidation-2                 173 ± 0%       173 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/advanced-generic 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)
_htmlResponse-2                 108 ± 0%       108 ± 0%     ~     (all equal)
_jsonBodyManual-2               195 ± 0%       195 ± 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)
_requestResponseMapping-2       169 ± 0%       169 ± 0%     ~     (all equal)
_validation-2                   170 ± 0%       170 ± 0%     ~     (all equal)
_noValidation-2                 173 ± 0%       173 ± 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                 36.3k ± 2%     34.8k ±10%     ~     (p=0.095 n=5+5)
_directGzipHead-2             36.7k ± 3%     36.2k ± 5%     ~     (p=0.690 n=5+5)
_noDirectGzip-2               6.72k ± 2%     6.63k ± 2%     ~     (p=0.222 n=5+5)
_directGzip_decode-2          1.85k ± 6%     1.76k ± 3%     ~     (p=0.151 n=5+5)
_noDirectGzip_decode-2        6.82k ± 1%     6.57k ± 3%   -3.71%  (p=0.008 n=5+5)
_jsonBody-2                   19.5k ± 2%     18.7k ± 1%   -3.86%  (p=0.008 n=5+5)
_jsonBodyValidation-2         17.1k ± 2%     16.7k ± 2%     ~     (p=0.095 n=5+5)
_outputHeaders-2              37.5k ± 2%     37.5k ± 3%     ~     (p=1.000 n=5+5)
_requestResponseMapping-2     19.9k ± 2%     19.1k ± 1%   -4.15%  (p=0.008 n=5+5)
_validation-2                 18.8k ± 3%     18.2k ± 2%   -3.23%  (p=0.032 n=5+5)
_noValidation-2               25.5k ± 3%     24.2k ± 3%   -5.12%  (p=0.032 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                 35.8k ± 1%     32.3k ±11%   -9.66%  (p=0.016 n=4+5)
_directGzipHead-2             35.7k ± 4%     33.8k ± 5%   -5.29%  (p=0.016 n=5+5)
_noDirectGzip-2               6.75k ± 2%     6.47k ± 1%   -4.05%  (p=0.008 n=5+5)
_directGzip_decode-2          1.90k ± 3%     1.79k ± 2%   -5.70%  (p=0.008 n=5+5)
_noDirectGzip_decode-2        6.71k ± 1%     6.59k ± 1%   -1.78%  (p=0.016 n=5+5)
_htmlResponse-2               22.5k ± 2%     22.0k ± 2%   -1.98%  (p=0.032 n=5+5)
_jsonBodyManual-2             31.4k ± 3%     29.9k ± 3%   -4.61%  (p=0.008 n=5+5)
_jsonBody-2                   21.7k ± 1%     20.8k ± 1%   -4.28%  (p=0.008 n=5+5)
_jsonBodyValidation-2         16.9k ± 4%     16.0k ± 2%   -5.40%  (p=0.008 n=5+5)
_outputHeaders-2              36.3k ± 3%     34.8k ± 2%   -4.00%  (p=0.016 n=5+5)
_requestResponseMapping-2     19.8k ± 3%     19.2k ± 4%     ~     (p=0.151 n=5+5)
_validation-2                 18.8k ± 3%     17.6k ± 2%   -6.34%  (p=0.008 n=5+5)
_noValidation-2               24.8k ± 2%     23.9k ± 4%   -3.39%  (p=0.032 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2                30.9k ±13%     30.7k ± 1%     ~     (p=0.190 n=5+4)
_ok-2                         31.4k ± 6%     30.2k ± 2%     ~     (p=0.151 n=5+5)
_invalidBody-2                22.3k ± 4%     21.2k ± 1%   -4.75%  (p=0.016 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.93kB ± 0%    3.94kB ± 0%   +0.38%  (p=0.008 n=5+5)
_directGzipHead-2            3.92kB ± 0%    3.94kB ± 0%   +0.42%  (p=0.008 n=5+5)
_noDirectGzip-2              7.10kB ±19%    7.15kB ±16%     ~     (p=0.841 n=5+5)
_directGzip_decode-2          403kB ± 0%     403kB ± 0%     ~     (p=0.548 n=5+5)
_noDirectGzip_decode-2       6.22kB ±10%    6.02kB ± 8%     ~     (p=0.421 n=5+5)
_jsonBody-2                  13.2kB ± 0%    13.3kB ± 0%     ~     (p=0.286 n=5+5)
_jsonBodyValidation-2        19.0kB ± 0%    19.0kB ± 0%     ~     (p=0.127 n=5+5)
_outputHeaders-2             3.71kB ± 0%    3.71kB ± 0%     ~     (p=0.619 n=5+5)
_requestResponseMapping-2    16.7kB ± 0%    16.7kB ± 0%     ~     (p=0.357 n=5+5)
_validation-2                16.6kB ± 0%    16.6kB ± 0%     ~     (p=0.151 n=5+5)
_noValidation-2              7.89kB ± 0%    7.90kB ± 0%     ~     (p=0.127 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                3.98kB ± 0%    3.99kB ± 0%   +0.39%  (p=0.008 n=5+5)
_directGzipHead-2            3.97kB ± 0%    3.99kB ± 0%   +0.39%  (p=0.008 n=5+5)
_noDirectGzip-2              7.22kB ±17%    7.57kB ±15%     ~     (p=0.690 n=5+5)
_directGzip_decode-2          403kB ± 0%     403kB ± 0%     ~     (p=0.730 n=5+5)
_noDirectGzip_decode-2       6.09kB ± 3%    6.15kB ± 4%     ~     (p=0.841 n=5+5)
_htmlResponse-2              8.26kB ± 0%    8.26kB ± 0%     ~     (p=0.571 n=5+5)
_jsonBodyManual-2            4.65kB ± 0%    4.65kB ± 0%     ~     (p=0.643 n=5+5)
_jsonBody-2                  10.4kB ± 0%    10.4kB ± 0%     ~     (p=0.063 n=4+5)
_jsonBodyValidation-2        19.1kB ± 0%    19.1kB ± 0%     ~     (p=0.889 n=5+5)
_outputHeaders-2             3.75kB ± 0%    3.75kB ± 0%     ~     (p=0.595 n=5+5)
_requestResponseMapping-2    16.8kB ± 0%    16.8kB ± 0%     ~     (p=0.690 n=5+5)
_validation-2                16.7kB ± 0%    16.7kB ± 0%     ~     (p=0.627 n=5+5)
_noValidation-2              7.96kB ± 0%    7.96kB ± 0%     ~     (p=0.365 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2               4.89kB ± 0%    4.89kB ± 0%     ~     (p=0.063 n=5+5)
_ok-2                        4.79kB ± 0%    4.79kB ± 0%     ~     (p=0.429 n=4+4)
_invalidBody-2               8.63kB ± 0%    8.64kB ± 0%     ~     (p=0.971 n=4+4)

name                       old allocs/op  new allocs/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2                  42.0 ± 0%      42.0 ± 0%     ~     (all equal)
_directGzipHead-2              42.0 ± 0%      42.0 ± 0%     ~     (all equal)
_noDirectGzip-2                49.8 ± 4%      49.8 ± 4%     ~     (p=1.000 n=5+5)
_directGzip_decode-2            502 ± 0%       502 ± 0%     ~     (p=1.000 n=5+5)
_noDirectGzip_decode-2         50.0 ± 0%      50.0 ± 0%     ~     (all equal)
_jsonBody-2                     130 ± 0%       130 ± 0%     ~     (all equal)
_jsonBodyValidation-2           186 ± 0%       186 ± 0%     ~     (all equal)
_outputHeaders-2               37.0 ± 0%      37.0 ± 0%     ~     (all equal)
_requestResponseMapping-2       126 ± 0%       126 ± 0%     ~     (all equal)
_validation-2                   155 ± 0%       155 ± 0%     ~     (all equal)
_noValidation-2                92.0 ± 0%      92.0 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                  44.0 ± 0%      44.0 ± 0%     ~     (all equal)
_directGzipHead-2              44.0 ± 0%      44.0 ± 0%     ~     (all equal)
_noDirectGzip-2                51.8 ± 3%      51.8 ± 3%     ~     (p=1.000 n=5+5)
_directGzip_decode-2            504 ± 0%       504 ± 0%     ~     (p=1.000 n=4+5)
_noDirectGzip_decode-2         52.0 ± 0%      52.0 ± 0%     ~     (all equal)
_htmlResponse-2                 145 ± 0%       145 ± 0%     ~     (all equal)
_jsonBodyManual-2              51.0 ± 0%      51.0 ± 0%     ~     (all equal)
_jsonBody-2                     102 ± 0%       102 ± 0%     ~     (all equal)
_jsonBodyValidation-2           188 ± 0%       188 ± 0%     ~     (all equal)
_outputHeaders-2               38.0 ± 0%      38.0 ± 0%     ~     (all equal)
_requestResponseMapping-2       128 ± 0%       128 ± 0%     ~     (all equal)
_validation-2                   157 ± 0%       157 ± 0%     ~     (all equal)
_noValidation-2                94.0 ± 0%      94.0 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2                 54.0 ± 0%      54.0 ± 0%     ~     (all equal)
_ok-2                          50.0 ± 0%      50.0 ± 0%     ~     (all equal)
_invalidBody-2                 99.0 ± 0%      99.0 ± 0%     ~     (all equal)

@vearutop vearutop merged commit 4c2485a into master Jan 19, 2023
@vearutop vearutop deleted the gzip-hijacker branch January 19, 2023 23:05
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.

Gzip middleware blocks websockets.
1 participant