-
Notifications
You must be signed in to change notification settings - Fork 65
Added ByteString benchmarks #194
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
Added benchmarks covering the following functions: - indexOf - lastIndexOf - startsWith - endsWith - hashCode - compareTo Fixes #153
} | ||
|
||
@Benchmark | ||
fun benchmark() = buffer.indexOf(byteString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, the result of indexOf
will always be 0?
I see, the zero byte is also equal to 0, so the length-1 of the bytestring is scanned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, every byte at a position whose index is a multiple of bytestring size is 0
, so the benchmark has to scan the whole buffer, every time looking for up to length-1
bytes ahead.
} | ||
|
||
@State(Scope.Benchmark) | ||
open class CompareBenchmark { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add tests on equals
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed. Added the benchmark.
Added benchmarks covering the following functions:
Fixes #153