Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Helper tool for perf improvement descriptions
This tool should help us consistify commit messages and changelog
entries. It prints the preferred form (e.g. β€œ2x as fast”) to stdout
and some extra variants are printed to stderr along with formulas that
were used. Note that I'm proposing β€œ2x as fast” variant because it is
very easy to calculate and relatively easy to understand. The script
should be modified if we decide to use something else.

The script doesn't handle 0 as new-time, and that's OK because
β€œβˆžx as fast” is not very clear anyway.

See also: https://randomascii.wordpress.com/2018/02/04/what-we-talk-about-when-we-talk-about-performance/
  • Loading branch information
AlexDaniel committed Jun 29, 2018
1 parent c37c3b5 commit e23e2f6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tools/speedup.p6
@@ -0,0 +1,37 @@
#!/usr/bin/env perl6

sub MAIN(
#| old measurement
\old-time,
#| new measurement (typically less than the old measurement)
\new-time,
#| old overhead of the bench script (e.g. rakudo startup time)
\old-overhead = 0,
#| new overhead of the bench script (by default same as old-overhead)
\new-overhead = old-overhead,
) {
my \old = old-time - old-overhead;
my \new = new-time - new-overhead;

put (old Γ· new).round(0.01), β€˜x as fast’;

note β€˜β€™;
note β€˜Given:’;
note β€˜old-time = ’, old-time;
note β€˜new-time = ’, new-time;
note β€˜old-overhead = ’, old-overhead;
note β€˜new-overhead = ’, new-overhead;
note β€˜β€™;
note β€˜old = ’, old-time - old-overhead,
β€˜ (old-time - old-overhead)’;
note β€˜new = ’, new-time - new-overhead,
β€˜ (new-time - new-overhead)’;

note β€˜β€™;
note β€˜All forms:’;
note old Γ· new, β€˜x as fast (old Γ· new)’;
note old Γ· new - 1, β€˜x faster (old Γ· new - 1)’;
note (old Γ· new - 1) Γ— 100, β€˜% faster ( (old Γ· new - 1) Γ— 100 )’;
note β€˜runs in ’,
new Γ· old Γ— 100, β€˜% of the time it used to (new Γ· old Γ— 100)’;
}

1 comment on commit e23e2f6

@lizmat
Copy link
Contributor

@lizmat lizmat commented on e23e2f6 Jun 29, 2018

Choose a reason for hiding this comment

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

πŸ‘

Please sign in to comment.