Raku Land

Benchy

Build Status

NAME

Benchy - Benchmark some code

SYNOPSIS

use Benchy; b 20_000, # number of times to loop { some-setup; my-old-code }, # your old version { some-setup; my-new-code }, # your new version { some-setup } # optional "bare" loop to eliminate setup code's time # SAMPLE OUTPUT: # Bare: 0.0606532677866851s # Old: 2.170558s # New: 0.185170s # NEW version is 11.72x faster

DESCRIPTION

Takes 2 Callables and measures which one is faster. Optionally takes a 3rd Callable that will be run the same number of times as other two callables, and the time it took to run will be subtracted from the other results.

EXPORTED PRAGMAS

MONKEY

The use of this module enables MONKEY pragma, so you can augment, use NQP, EVAL, etc, without needing to specify those pragmas.

EXPORTED SUBROUTINES

b

Defined as:

sub b (int $n, &old, &new, &bare = { $ = $ }, :$silent)

Benches the codes and prints the results. Will print in colour, if Terminal::ANSIColor is installed.

Args:

[1] Note that the exact number to loop will always be evened out, as the bench splits the work into two chunks that are measured at different times, so the total time is 2 × floor ½ × $n

Return value:

Returns a hash with three keys—bare, new, and old—whose values are Duration objects representing the time it took the corresponding Callables to run. NOTE: the new and old already have the duration of bare subtracted from them.

{ :bare(Duration.new(<32741983139/488599474770>)), :new(Duration.new(<167/956>)), :old(Duration.new(<1280561957330937733/590077351150947660>)) }

REPOSITORY

Fork this module on GitHub: https://github.com/raku-community-modules/Benchy

BUGS

To report bugs or request features, please use https://github.com/raku-community-modules/Benchy/issues

AUTHOR

Zoffix Znet (http://perl6.party/)

LICENSE

You can use and distribute this module under the terms of the The Artistic License 2.0. See the LICENSE file included in this distribution for complete details.

The META6.json file of this distribution may be distributed and modified without restrictions or attribution.