Skip to content
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

Sort reports using an algorithm that handles multi-digit numbers well #835

Open
HadrienG2 opened this issue Dec 23, 2024 · 0 comments
Open

Comments

@HadrienG2
Copy link

HadrienG2 commented Dec 23, 2024

Currently, criterion report entries are sorted using a simple codepoint-wise lexicographic string sort. This does not work well for benchmarks that cover a wide range of a numerical values for a certain parameter, such that numbers in benchmark/group names do not have the same number of digits.

For example, if I probe a parameter at values 1, 2, 4, 8, 16, criterion report entries will end up in this unpleasant order:

  • 1
  • 16
  • 2
  • 4
  • 8

If would be nice if criterion could instead use a multi-digit number aware string sorting algorithm that conceptually splits strings into chunks of digits and non-digits, converts chunks of digits into integers, and then sorts the resulting (str, int, str, int...) tuples lexicographically. From memory, this is what the Windows file explorer does when sorting files by name.

In absence of a fix for this, criterion benchmarks can work around this criterion limitation by adding as many leading zeros as needed to numbers in benchmark names so that all numbers have the same number of digits. But this comes at the expense of slightly less readable benchmark names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant