Skip to content

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

Merged
merged 4 commits into from
Aug 8, 2023
Merged

Added ByteString benchmarks #194

merged 4 commits into from
Aug 8, 2023

Conversation

fzhinkin
Copy link
Collaborator

@fzhinkin fzhinkin commented Aug 2, 2023

Added benchmarks covering the following functions:

  • indexOf
  • lastIndexOf
  • startsWith
  • endsWith
  • hashCode
  • compareTo

Fixes #153

Added benchmarks covering the following functions:
- indexOf
- lastIndexOf
- startsWith
- endsWith
- hashCode
- compareTo

Fixes #153
@fzhinkin fzhinkin self-assigned this Aug 2, 2023
@fzhinkin fzhinkin linked an issue Aug 2, 2023 that may be closed by this pull request
@fzhinkin fzhinkin marked this pull request as ready for review August 2, 2023 11:53
@fzhinkin fzhinkin requested a review from shanshin August 2, 2023 11:53
}

@Benchmark
fun benchmark() = buffer.indexOf(byteString)
Copy link
Contributor

@shanshin shanshin Aug 6, 2023

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

Copy link
Collaborator Author

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 {
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@fzhinkin fzhinkin merged commit 387146a into develop Aug 8, 2023
@fzhinkin fzhinkin deleted the bytestring-benchmarks branch August 8, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend benchmarking suite with ByteString-related benchmarks
2 participants