NAME

Bencher::Scenario::CBlocks::Numeric - Benchmark numeric performance of C::Blocks

VERSION

This document describes version 0.002 of Bencher::Scenario::CBlocks::Numeric (from Perl distribution Bencher-Scenarios-CBlocks), released on 2017-01-25.

SYNOPSIS

To run benchmark with default option:

% bencher -m CBlocks::Numeric

To run module startup overhead benchmark:

% bencher --module-startup -m CBlocks::Numeric

For more options (dump scenario, list/include/exclude/add participants, list/include/exclude/add datasets, etc), see bencher or run bencher --help.

DESCRIPTION

Each code generates random number (the perl participant using pure-perl code.

Packaging a benchmark script as a Bencher scenario makes it convenient to include/exclude/add participants/datasets (either via CLI or Perl code), send the result to a central repository, among others . See Bencher and bencher (CLI) for more details.

BENCHMARKED MODULES

Version numbers shown below are the versions used when running the sample benchmark.

C::Blocks 0.41

BENCHMARK PARTICIPANTS

  • perl (perl_code)

    Code template:

    my $a = 698769069;
    my ($x, $y, $z, $c) = (123456789, 362436000, 521288629, 7654321);
    my $rand;
    for (1 .. <N>) {
        my $t;
        $x = 69069*$x+12345;
        $y ^= ($y<<13); $y ^= ($y>>17); $y ^= ($y<<5);
        $t = $a*$z+$c; $c = ($t>>32);
        $z = $t;
        $rand = $x+$y+$z;
    }
    return $rand;
  • C::Blocks (perl_code)

    Code template:

    use C::Blocks;
    use C::Blocks::Types qw(uint);
    clex {
        /* Note: y must never be set to zero;
         * z and c must not be simultaneously zero */
        unsigned int x = 123456789,y = 362436000,
            z = 521288629,c = 7654321; /* State variables */
    
        unsigned int KISS() {
            unsigned long long t, a = 698769069ULL;
            x = 69069*x+12345;
            y ^= (y<<13); y ^= (y>>17); y ^= (y<<5);
            t = a*z+c; c = (t>>32);
            return x+y+(z=t);
        }
    }
    
    my uint $to_return = 0;
    cblock {
        for (int i = 0; i < <N>; i++) $to_return = KISS();
    }
    return $to_return;

BENCHMARK DATASETS

  • 10

  • 31

  • 100

  • 316

  • 1000

  • 3235

  • 10000

  • 31622

  • 100000

  • 316227

SAMPLE BENCHMARK RESULTS

Run on: perl: v5.24.0, CPU: Intel(R) Core(TM) M-5Y71 CPU @ 1.20GHz (2 cores), OS: GNU/Linux LinuxMint version 17.3, OS kernel: Linux version 3.19.0-32-generic.

Benchmark with default options (bencher -m CBlocks::Numeric):

#table1#
+-------------+---------+-----------+------------+------------+-----------+---------+
| participant | dataset | rate (/s) | time (ms)  | vs_slowest |  errors   | samples |
+-------------+---------+-----------+------------+------------+-----------+---------+
| C::Blocks   | 316227  |       6.1 | 160        |        1   |   0.00028 |       7 |
| perl        | 316227  |       6.8 | 150        |        1.1 |   0.00075 |       6 |
| C::Blocks   | 100000  |      20   |  50        |        3   |   0.00089 |       7 |
| perl        | 100000  |      20   |  50        |        3   |   0.00069 |       6 |
| perl        | 31622   |      70   |  10        |       10   |   0.00023 |       6 |
| C::Blocks   | 10000   |     100   |   7        |       20   |   0.00036 |      10 |
| perl        | 10000   |     219   |   4.57     |       35.9 | 2.4e-06   |       6 |
| C::Blocks   | 3235    |     400   |   2.5      |       66   |   2e-05   |       9 |
| perl        | 3235    |     654   |   1.53     |      107   | 2.9e-07   |       6 |
| C::Blocks   | 1000    |    1000   |   0.9      |      200   | 1.4e-05   |       7 |
| perl        | 1000    |    2290   |   0.436    |      376   | 3.9e-07   |       6 |
| C::Blocks   | 31622   |    2900   |   0.34     |      480   | 4.9e-07   |       6 |
| C::Blocks   | 316     |    5800   |   0.17     |      950   | 8.8e-07   |       6 |
| perl        | 316     |    7200   |   0.14     |     1200   | 2.9e-07   |      11 |
| C::Blocks   | 100     |   18539   |   0.053939 |     3043.9 | 6.7e-11   |       6 |
| perl        | 100     |   23000   |   0.044    |     3700   | 6.8e-08   |       7 |
| C::Blocks   | 31      |   30000   |   0.03     |     5000   | 6.2e-07   |       9 |
| perl        | 31      |   65330   |   0.01531  |    10730   |   5e-10   |       6 |
| C::Blocks   | 10      |  100000   |   0.0096   |    17000   | 2.4e-08   |       6 |
| perl        | 10      |  190000   |   0.0053   |    31000   | 1.5e-08   |       6 |
+-------------+---------+-----------+------------+------------+-----------+---------+

Benchmark module startup overhead (bencher -m CBlocks::Numeric --module-startup):

#table2#
+---------------------+------------------------------+--------------------+----------------+-----------+------------------------+------------+-----------+---------+
| participant         | proc_private_dirty_size (MB) | proc_rss_size (MB) | proc_size (MB) | time (ms) | mod_overhead_time (ms) | vs_slowest |  errors   | samples |
+---------------------+------------------------------+--------------------+----------------+-----------+------------------------+------------+-----------+---------+
| C::Blocks           | 2.4                          | 6                  | 22             |        23 |                     17 |          1 |   0.00011 |       6 |
| perl -e1 (baseline) | 0.8                          | 4                  | 20             |         6 |                      0 |          4 | 6.3e-05   |       7 |
+---------------------+------------------------------+--------------------+----------------+-----------+------------------------+------------+-----------+---------+

To display as an interactive HTML table on a browser, you can add option --format html+datatables.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Bencher-Scenarios-CBlocks.

SOURCE

Source repository is at https://github.com/perlancar/perl-Bencher-Scenarios-CBlocks.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Bencher-Scenarios-CBlocks

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.