-
Notifications
You must be signed in to change notification settings - Fork 18.5k
strings: use Builder in Repeat to avoid an allocation #25894
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
Conversation
benchmark old ns/op new ns/op delta BenchmarkRepeat/length-1-4 290 225 -22.41% BenchmarkRepeat/length-5-4 621 391 -37.04% BenchmarkRepeat/length-10-4 900 556 -38.22% benchmark old allocs new allocs delta BenchmarkRepeat/length-1-4 2 1 -50.00% BenchmarkRepeat/length-5-4 2 1 -50.00% BenchmarkRepeat/length-10-4 2 1 -50.00%
|
This PR (HEAD: c1ad6e7) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/#/c/go/+/118855 to see it. Tip: You can toggle comments from me using the |
|
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit Bot: Uploaded patch set 2: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Brad Fitzpatrick: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit Bot: Uploaded patch set 3: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit Bot: Uploaded patch set 4: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Ilya Tocar: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
This PR (HEAD: 3d2e842) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/#/c/go/+/118855 to see it. Tip: You can toggle comments from me using the |
|
Message from Gerrit Bot: Uploaded patch set 6: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Tapir Liu: Patch Set 6:
yes, it was benchcmp. Switched to benchstat now. The outer loop is removed now. Thanks. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
4016de0 to
d2f663c
Compare
|
Message from Gerrit User 27938: Patch Set 12: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 12446: Uploaded patch set 13: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 12446: Uploaded patch set 14: New patch set was added with same tree, parent, and commit message as Patch Set 13. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 16006: Patch Set 14: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 12446: Uploaded patch set 15: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 12446: Uploaded patch set 16: New patch set was added with same tree, parent, and commit message as Patch Set 15. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 12446: Uploaded patch set 17: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 5065: Patch Set 17: Code-Review+2 I tweaked the PR title on GitHub. I'm happy with this when Martin's happy with the benchmarks. I'd try to keep the benchmarks names short-ish if possible. Maybe even like: Repeat/1x4 etc Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 16006: Patch Set 17: length times count
or for just counts
Would be good to keep the number of sub benchmarks within reason e.g. 6 or so. Otherwise code looks good. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 27938: Patch Set 18: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 5065: Patch Set 18: Please change code & commit message both to benchmarks named in "NxM" style. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 27938: Patch Set 18: (7 comments)
ok, will do it tomorrow. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 27938: Patch Set 19: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 12446: Uploaded patch set 20: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 27938: Patch Set 19: (2 comments)
Benchmark will be the following one by newest reviewings. func BenchmarkRepeat(b *testing.B) { Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 16006: Patch Set 20: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 27938: Patch Set 22: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 12446: Uploaded patch set 23: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 5065: Patch Set 23: You need to fix the commit message on GitHub since you started on GitHub. Edit the PR description. That's what makes the commit message here. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 12446: Uploaded patch set 24: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 27938: Patch Set 24: (1 comment)
done. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 5065: Patch Set 24: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 5976: Patch Set 24: TryBots beginning. Status page: https://farmer.golang.org/try?commit=0861ea44 Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
Message from Gerrit User 5976: Patch Set 24: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/118855. |
|
This PR is being closed because golang.org/cl/118855 has been merged. |
name old time/op new time/op delta Repeat/5x1-4 95.9ns ± 2% 70.1ns ± 2% -26.93% (p=0.000 n=9+10) Repeat/5x2-4 146ns ± 3% 100ns ± 2% -31.99% (p=0.000 n=10+10) Repeat/5x6-4 203ns ± 3% 140ns ± 4% -30.77% (p=0.000 n=10+10) Repeat/10x1-4 139ns ± 3% 92ns ± 4% -34.08% (p=0.000 n=10+10) Repeat/10x2-4 188ns ± 4% 122ns ± 2% -35.34% (p=0.000 n=10+10) Repeat/10x6-4 264ns ± 5% 179ns ± 4% -32.15% (p=0.000 n=10+10) name old alloc/op new alloc/op delta Repeat/5x1-4 10.0B ± 0% 5.0B ± 0% -50.00% (p=0.000 n=10+10) Repeat/5x2-4 32.0B ± 0% 16.0B ± 0% -50.00% (p=0.000 n=10+10) Repeat/5x6-4 64.0B ± 0% 32.0B ± 0% -50.00% (p=0.000 n=10+10) Repeat/10x1-4 32.0B ± 0% 16.0B ± 0% -50.00% (p=0.000 n=10+10) Repeat/10x2-4 64.0B ± 0% 32.0B ± 0% -50.00% (p=0.000 n=10+10) Repeat/10x6-4 128B ± 0% 64B ± 0% -50.00% (p=0.000 n=10+10) Change-Id: I6619336da636df39c560f6cc481519f48c6e8176 GitHub-Last-Rev: 4b2c73f GitHub-Pull-Request: #25894 Reviewed-on: https://go-review.googlesource.com/118855 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
name old time/op new time/op delta
Repeat/5x1-4 95.9ns ± 2% 70.1ns ± 2% -26.93% (p=0.000 n=9+10)
Repeat/5x2-4 146ns ± 3% 100ns ± 2% -31.99% (p=0.000 n=10+10)
Repeat/5x6-4 203ns ± 3% 140ns ± 4% -30.77% (p=0.000 n=10+10)
Repeat/10x1-4 139ns ± 3% 92ns ± 4% -34.08% (p=0.000 n=10+10)
Repeat/10x2-4 188ns ± 4% 122ns ± 2% -35.34% (p=0.000 n=10+10)
Repeat/10x6-4 264ns ± 5% 179ns ± 4% -32.15% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
Repeat/5x1-4 10.0B ± 0% 5.0B ± 0% -50.00% (p=0.000 n=10+10)
Repeat/5x2-4 32.0B ± 0% 16.0B ± 0% -50.00% (p=0.000 n=10+10)
Repeat/5x6-4 64.0B ± 0% 32.0B ± 0% -50.00% (p=0.000 n=10+10)
Repeat/10x1-4 32.0B ± 0% 16.0B ± 0% -50.00% (p=0.000 n=10+10)
Repeat/10x2-4 64.0B ± 0% 32.0B ± 0% -50.00% (p=0.000 n=10+10)
Repeat/10x6-4 128B ± 0% 64B ± 0% -50.00% (p=0.000 n=10+10)