Open
Conversation
Owner
|
Interesting approach! I think we'll keep this on the backburner though, as it's not an order of magnitude faster. In such cases I think I prefer to keep the code simple(r). Zero allocations are obviously another argument for it, so I'll keep this PR in mind. |
Contributor
Author
Makes sense. We can see if it helps in package |
Contributor
Author
|
Improvement for wordwrap performance OLD: BenchmarkWordWrapString-8 801043 1330 ns/op 879 B/op 11 allocs/op
BenchmarkWordWrapString-8 924964 1347 ns/op 879 B/op 11 allocs/op
BenchmarkWordWrapString-8 1000000 1317 ns/op 879 B/op 11 allocs/op
BenchmarkWordWrapString-8 990302 1317 ns/op 879 B/op 11 allocs/op
BenchmarkWordWrapString-8 869684 1355 ns/op 879 B/op 11 allocs/op
BenchmarkWordWrapString-8 933944 1350 ns/op 879 B/op 11 allocs/op
BenchmarkWordWrapString-8 912145 1353 ns/op 876 B/op 11 allocs/op
BenchmarkWordWrapString-8 1000000 1336 ns/op 873 B/op 11 allocs/op
BenchmarkWordWrapString-8 768968 1320 ns/op 867 B/op 11 allocs/op
BenchmarkWordWrapString-8 927973 1358 ns/op 879 B/op 11 allocs/opNEW: BenchmarkWordWrapString-8 1000000 1010 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1213159 991 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1234002 952 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1000000 1006 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1000000 1006 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1244863 1012 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1233816 977 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1241438 1017 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1000000 1024 ns/op 0 B/op 0 allocs/op
BenchmarkWordWrapString-8 1000000 1007 ns/op 0 B/op 0 allocs/opbenchstat: name old time/op new time/op delta
WordWrapString-8 1.34µs ± 2% 1.01µs ± 3% -24.86% (p=0.000 n=10+9)
name old alloc/op new alloc/op delta
WordWrapString-8 878B ± 1% 0B -100.00% (p=0.000 n=9+10)
name old allocs/op new allocs/op delta
WordWrapString-8 11.0 ± 0% 0.0 -100.00% (p=0.000 n=10+10) |
Contributor
Author
|
Update newest benchstat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey @muesli !
In this improvement, I use
unsafeto convert byte slice to a string without memory allocation which is heavily used by fasthttp.OLD:
NEW:
Benchstat:
I don’t know if you mind this trick of using unsafe, so feel free to close this PR directly.