Skip to content

Conversation

@imxyb
Copy link
Contributor

@imxyb imxyb commented Sep 15, 2020

benchcmp result:

benchcmp is deprecated in favor of benchstat: https://pkg.go.dev/golang.org/x/perf/cmd/benchstat benchmark old ns/op new ns/op delta BenchmarkRealIPForHeaderXForwardFor-12 128 39.7 -68.98% 

before:

goos: darwin goarch: amd64 pkg: github.com/labstack/echo/v4 BenchmarkRealIP-12 8774244 130 ns/op 48 B/op 1 allocs/op PASS ok github.com/labstack/echo/v4 1.297s 

after:

goos: darwin goarch: amd64 pkg: github.com/labstack/echo/v4 BenchmarkRealIP-12 28132903 38.2 ns/op 0 B/op 0 allocs/op PASS ok github.com/labstack/echo/v4 1.133s 
@codecov
Copy link

codecov bot commented Sep 15, 2020

Codecov Report

Merging #1640 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #1640 +/- ## ========================================== + Coverage 85.28% 85.30% +0.01%  ========================================== Files 28 28 Lines 2216 2219 +3 ========================================== + Hits 1890 1893 +3  Misses 212 212 Partials 114 114 
Impacted Files Coverage Δ
context.go 89.84% <100.00%> (+0.12%) ⬆️

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 151ed6b...64c4950. Read the comment docs.

@lammel
Copy link
Contributor

lammel commented Sep 15, 2020

The title says IndexByte but in the code string.IndexAny() is used.
IndexByte cam with Go 1.2 so that is also fine. Tests should be adjusted to cover the missing cases (as code coverage dropped)

What was used in the benchmarks actually?

@lammel lammel self-assigned this Sep 15, 2020
@imxyb imxyb changed the title Use IndexByte instead of Split to reduce memory allocation Use IndexAny instead of Split to reduce memory allocation Sep 16, 2020
@imxyb
Copy link
Contributor Author

imxyb commented Sep 16, 2020

The title says IndexByte but in the code string.IndexAny() is used.
IndexByte cam with Go 1.2 so that is also fine. Tests should be adjusted to cover the missing cases (as code coverage dropped)

What was used in the benchmarks actually?

sorry, the title is incorrect, I have changed it back and use IndexAny correctly.I will improve the test coverage later

@imxyb
Copy link
Contributor Author

imxyb commented Sep 17, 2020

@lammel PTAL

@lammel
Copy link
Contributor

lammel commented Sep 17, 2020

Nice! Will take a look later on.

@imxyb
Copy link
Contributor Author

imxyb commented Oct 15, 2020

hi,any update? @lammel

@lammel
Copy link
Contributor

lammel commented Nov 5, 2020

Tested for benchmark regressions on the PR branch.

PR branch feature/opt-split:

sh# /usr/bin/go test -benchmem -run=^$ github.com/labstack/echo/v4 -bench ^Benchmark -benchtime 5s goos: linux goarch: amd64 pkg: github.com/labstack/echo/v4 BenchmarkBindbindData-8 773809 8006 ns/op 368 B/op 40 allocs/op BenchmarkBindbindDataWithTags-8 600234 9815 ns/op 408 B/op 39 allocs/op BenchmarkAllocJSONP-8	16191808 369 ns/op 155 B/op 4 allocs/op BenchmarkAllocJSON-8	24182094 240 ns/op 95 B/op 1 allocs/op BenchmarkAllocXML-8 4307667 1398 ns/op 4751 B/op 10 allocs/op BenchmarkRealIPForHeaderXForwardFor-8	152748471 38.7 ns/op 0 B/op 0 allocs/op BenchmarkContext_Store-8	133940372 44.3 ns/op 0 B/op 0 allocs/op BenchmarkRouterStaticRoutes-8 484891 12681 ns/op 0 B/op 0 allocs/op BenchmarkRouterGitHubAPI-8 249950 23171 ns/op 0 B/op 0 allocs/op BenchmarkRouterParseAPI-8 1406133 4247 ns/op 0 B/op 0 allocs/op BenchmarkRouterGooglePlusAPI-8 884396 6860 ns/op 0 B/op 0 allocs/op PASS ok	github.com/labstack/echo/v4	81.256s 

compared to current master:

 /usr/bin/go test -benchmem -run=^$ github.com/labstack/echo/v4 -bench ^Benchmark -benchtime 5s goos: linux goarch: amd64 pkg: github.com/labstack/echo/v4 BenchmarkBindbindData-8 763737 8278 ns/op 368 B/op 40 allocs/op BenchmarkBindbindDataWithTags-8 599168 9928 ns/op 408 B/op 39 allocs/op BenchmarkAllocJSONP-8	16310584 377 ns/op 154 B/op 4 allocs/op BenchmarkAllocJSON-8	24018079 244 ns/op 95 B/op 1 allocs/op BenchmarkAllocXML-8 4306189 1411 ns/op 4751 B/op 10 allocs/op BenchmarkRealIPForHeaderXForwardFor-8	49710991 114 ns/op 48 B/op 1 allocs/op BenchmarkContext_Store-8	132688436 47.3 ns/op 0 B/op 0 allocs/op BenchmarkRouterStaticRoutes-8 539204 11651 ns/op 0 B/op 0 allocs/op BenchmarkRouterGitHubAPI-8 259131 23709 ns/op 0 B/op 0 allocs/op BenchmarkRouterParseAPI-8 1487281 4015 ns/op 0 B/op 0 allocs/op BenchmarkRouterGooglePlusAPI-8 919380 6719 ns/op 0 B/op 0 allocs/op PASS ok	github.com/labstack/echo/v4	78.373s 

No regressions seen. PR looks OK.
Thanks a lot @imxyb . Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants