Skip to content

refactor: simplify decoder & handler, add tests#89

Merged
abemedia merged 1 commit into
masterfrom
refactor/decoder
May 6, 2023
Merged

refactor: simplify decoder & handler, add tests#89
abemedia merged 1 commit into
masterfrom
refactor/decoder

Conversation

@abemedia

@abemedia abemedia commented May 5, 2023

Copy link
Copy Markdown
Owner
  • Split request parsing out of handler.
  • Reduce duplicate code in decoder compile.
  • Remove type specific decoders.
  • Remove tag check.
  • Improve decoder test coverage.

@abemedia abemedia force-pushed the refactor/decoder branch from 9f93dcc to fbca6d3 Compare May 6, 2023 03:01
@abemedia abemedia force-pushed the refactor/decoder branch from fbca6d3 to c1cf53e Compare May 6, 2023 03:51
@codecov

codecov Bot commented May 6, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 81.48% and project coverage change: +7.16 🎉

Comparison is base (f0c21df) 73.74% compared to head (c1cf53e) 80.90%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #89      +/-   ##
==========================================
+ Coverage   73.74%   80.90%   +7.16%     
==========================================
  Files          23       19       -4     
  Lines         899      770     -129     
==========================================
- Hits          663      623      -40     
+ Misses        201      119      -82     
+ Partials       35       28       -7     
Impacted Files Coverage Δ
decoder/decode.go 56.25% <43.75%> (+56.25%) ⬆️
decoder/adapters.go 69.38% <69.38%> (ø)
decoder/compile.go 83.33% <95.45%> (+5.02%) ⬆️
encoding/form/form.go 72.72% <100.00%> (ø)
handler.go 96.61% <100.00%> (-1.31%) ⬇️
request.go 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions

github-actions Bot commented May 6, 2023

Copy link
Copy Markdown
Contributor

Benchmark Result

Benchmark diff with base branch
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don
cpu: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
          │ bench-master.txt │           bench-new.txt            │
          │      sec/op      │   sec/op     vs base               │
Handler-2        470.0n ± 0%   463.2n ± 1%  -1.44% (p=0.001 n=10)

          │ bench-master.txt │         bench-new.txt          │
          │       B/op       │    B/op     vs base            │
Handler-2         72.00 ± 0%   72.00 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

          │ bench-master.txt │         bench-new.txt          │
          │    allocs/op     │ allocs/op   vs base            │
Handler-2         2.000 ± 0%   2.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

pkg: github.com/abemedia/go-don/decoder
                    │ bench-master.txt │           bench-new.txt            │
                    │      sec/op      │   sec/op     vs base               │
Decoder/Gorilla-2          19.03µ ± 1%   19.13µ ± 1%  +0.53% (p=0.008 n=10)
Decoder/DonCached-2        942.7n ± 2%   947.1n ± 1%  +0.46% (p=0.015 n=10)
Decoder/Don-2              987.1n ± 0%   994.2n ± 1%  +0.72% (p=0.002 n=10)
geomean                    2.606µ        2.621µ       +0.57%

                    │ bench-master.txt │             bench-new.txt             │
                    │       B/op       │     B/op      vs base                 │
Decoder/Gorilla-2         2.500Ki ± 0%   2.500Ki ± 0%       ~ (p=1.000 n=10) ¹
Decoder/DonCached-2         176.0 ± 0%     176.0 ± 0%       ~ (p=1.000 n=10) ¹
Decoder/Don-2               176.0 ± 0%     176.0 ± 0%       ~ (p=1.000 n=10) ¹
geomean                     429.6          429.6       +0.00%
¹ all samples are equal

                    │ bench-master.txt │            bench-new.txt            │
                    │    allocs/op     │ allocs/op   vs base                 │
Decoder/Gorilla-2           166.0 ± 0%   166.0 ± 0%       ~ (p=1.000 n=10) ¹
Decoder/DonCached-2         3.000 ± 0%   3.000 ± 0%       ~ (p=1.000 n=10) ¹
Decoder/Don-2               3.000 ± 0%   3.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                     11.43        11.43       +0.00%
¹ all samples are equal
Benchmark result
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don
cpu: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
          │ bench-new.txt │
          │    sec/op     │
Handler-2     463.2n ± 1%

          │ bench-new.txt │
          │     B/op      │
Handler-2      72.00 ± 0%

          │ bench-new.txt │
          │   allocs/op   │
Handler-2      2.000 ± 0%

pkg: github.com/abemedia/go-don/decoder
                    │ bench-new.txt │
                    │    sec/op     │
Decoder/Gorilla-2       19.13µ ± 1%
Decoder/DonCached-2     947.1n ± 1%
Decoder/Don-2           994.2n ± 1%
geomean                 2.621µ

                    │ bench-new.txt │
                    │     B/op      │
Decoder/Gorilla-2      2.500Ki ± 0%
Decoder/DonCached-2      176.0 ± 0%
Decoder/Don-2            176.0 ± 0%
geomean                  429.6

                    │ bench-new.txt │
                    │   allocs/op   │
Decoder/Gorilla-2        166.0 ± 0%
Decoder/DonCached-2      3.000 ± 0%
Decoder/Don-2            3.000 ± 0%
geomean                  11.43

@abemedia abemedia changed the title refactor: simplify decoder, add tests refactor: simplify decoder & handler, add tests May 6, 2023
@abemedia abemedia enabled auto-merge (squash) May 6, 2023 04:05
@abemedia abemedia merged commit 060d18a into master May 6, 2023
@abemedia abemedia deleted the refactor/decoder branch May 6, 2023 04: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.

1 participant