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

Fix stats printing for floats and negative deltas #357

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

rwstauner
Copy link
Contributor

This allows tracking ratio_in_yjit which was previously printing as ratio_in_yjit: 97,01,453,835,082,627.

$ YJIT_BENCH_STATS=ratio_in_yjit ./run_benchmarks.rb --chruby 'ruby-master --yjit-stats=quiet' hexapdf
...
itr:   time ratio_in_yjit
 #1: 2942ms  90.7154624209111
 #2: 2020ms  4.721474016014753
 #3: 1887ms  1.5029409662104598
 #4: 1926ms -0.7787970216063087
 #5: 1936ms  0.7501346345277966
 #6: 1926ms  0.49650225551091864
...
ratio_in_yjit:      97.01453835082627

Ratio in YJIT might print something like this:
 #8: 1918ms  0.305937303071417
 #9: 1950ms -0.396978503607869
@rwstauner rwstauner force-pushed the rwstauner/ratio-in-yjit branch from 5d2dc4c to 3bc4100 Compare January 21, 2025 23:55
Comment on lines 63 to 70
# Insert comma separators but only in the whole number portion.
diff = (new_value - old_value).to_s.split(".").tap do |a|
# Preserve any leading minus sign that may be on the beginning.
a[0] = a[0].reverse.scan(/\d{1,3}-?/).join(",").reverse
# Add a space when positive so that if there is ever a negative
# the first digit will line up.
a[0].prepend(" ") unless a[0].start_with?("-")
end.join(".")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be code to put this in a utility function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I hesitated because we've talked before about how additional definitions in the global env can have an affect on the benchmark, but it would allow us to reuse it in the other location

@maximecb maximecb merged commit 35773de into main Jan 22, 2025
4 checks passed
@maximecb maximecb deleted the rwstauner/ratio-in-yjit branch January 22, 2025 16:38
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

Successfully merging this pull request may close these issues.

2 participants