komuw / ong

ong, is a Go http toolkit.
MIT License
16 stars 4 forks source link

Improve log perfomance #359

Closed komuw closed 11 months ago

komuw commented 11 months ago

The performance for the average case seems to be 7% slower compared to v0.0.73. But for the best case, it is about 45% faster.

go test -timeout 7m -count=10 -run=XXXX -bench=BenchmarkAverageCase/ong github.com/komuw/ong/log > old.txt
go test -timeout 7m -count=10 -run=XXXX -bench=BenchmarkAverageCase/ong github.com/komuw/ong/log > new.txt
benchstat old.txt new.txt

pkg: github.com/komuw/ong/log
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
                  │   old.txt   │              new.txt               │
                  │   sec/op    │   sec/op     vs base               │
AverageCase/ong-8   5.287µ ± 4%   5.678µ ± 6%  +7.41% (p=0.000 n=10)

                  │   old.txt    │               new.txt               │
                  │     B/op     │     B/op      vs base               │
AverageCase/ong-8   1.475Ki ± 0%   1.567Ki ± 0%  +6.29% (p=0.000 n=10)

                  │  old.txt   │              new.txt              │
                  │ allocs/op  │ allocs/op   vs base               │
AverageCase/ong-8   27.00 ± 0%   26.00 ± 0%  -3.70% (p=0.000 n=10)

go test -timeout 7m -count=10 -run=XXXX -bench=BenchmarkBestCase/ong github.com/komuw/ong/log > old.txt
go test -timeout 7m -count=10 -run=XXXX -bench=BenchmarkBestCase/ong github.com/komuw/ong/log > new.txt
benchstat old.txt new.txt

pkg: github.com/komuw/ong/log
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
               │   old.txt   │               new.txt               │
               │   sec/op    │   sec/op     vs base                │
BestCase/ong-8   2.315µ ± 2%   1.253µ ± 7%  -45.90% (p=0.000 n=10)

               │   old.txt   │              new.txt               │
               │    B/op     │    B/op     vs base                │
BestCase/ong-8   1024.0 ± 0%   864.0 ± 0%  -15.62% (p=0.000 n=10)

               │   old.txt   │              new.txt               │
               │  allocs/op  │ allocs/op   vs base                │
BestCase/ong-8   19.000 ± 0%   2.000 ± 0%  -89.47% (p=0.000 n=10)
codecov-commenter commented 11 months ago

Codecov Report

Patch coverage: 88.00% and project coverage change: -0.04% :warning:

Comparison is base (0185295) 75.39% compared to head (267a954) 75.35%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #359 +/- ## ========================================== - Coverage 75.39% 75.35% -0.04% ========================================== Files 44 44 Lines 5104 5109 +5 ========================================== + Hits 3848 3850 +2 - Misses 997 999 +2 - Partials 259 260 +1 ``` | [Files Changed](https://app.codecov.io/gh/komuw/ong/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Komu+Wairagu) | Coverage Δ | | |---|---|---| | [log/slogtest.go](https://app.codecov.io/gh/komuw/ong/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Komu+Wairagu#diff-bG9nL3Nsb2d0ZXN0Lmdv) | `76.66% <ø> (ø)` | | | [log/log.go](https://app.codecov.io/gh/komuw/ong/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Komu+Wairagu#diff-bG9nL2xvZy5nbw==) | `94.33% <88.00%> (-1.77%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.