App-BencherUtils

 view release on metacpan or  search on metacpan

lib/App/BencherUtils.pm  view on Meta::CPAN

                                      participant_types
                                     /]}
        if $detail;

    [200, "OK", \@res, $resmeta];
}

$SPEC{format_bencher_result} = {
    v => 1.1,
    summary => 'Format bencher raw/JSON result',
    args => {
        json => {
            summary => 'JSON data',
            schema => 'str*', # XXX filename
            req => 1,
            pos => 0,
            cmdline_src => 'stdin_or_file',
        },
        as => {
            schema => ['str*', in=>[qw/bencher_table benchmark_pm_table/]],
            default => 'bencher_table',
        },
    },
};
sub format_bencher_result {
    require Bencher::Backend;

    my %args = @_;
    my $res = _json->decode($args{json});
    [200, "OK", Bencher::Backend::format_result($res, undef, {
        ($args{as} eq 'bencher_table' ? (render_as_text_table=>1) : ()),
        ($args{as} eq 'benchmark_pm_table' ? (render_as_benchmark_pm=>1) : ()),
    }),
     {'cmdline.skip_format'=>1}];
}

$SPEC{chart_bencher_result} = {
    v => 1.1,
    summary => 'Generate chart of bencher result and display it',
    args => {
        json => {
            summary => 'JSON data',
            schema => 'str*', # XXX filename
            req => 1,
            pos => 0,
            cmdline_src => 'stdin_or_file',
        },
    },
};
sub chart_bencher_result {
    require Bencher::Backend;
    require Browser::Open;
    require File::Temp;

    my %args = @_;

    my $envres = _json->decode($args{json});

    my ($temp_fh, $temp_fname) = File::Temp::tempfile();

    $temp_fname .= ".png";

    my $chart_res = Bencher::Backend::chart_result(
        envres => $envres, output_file => $temp_fname, overwrite=>1);

    return $chart_res if $chart_res->[0] != 200;

    my $view_res = Browser::Open::open_browser("file:$temp_fname");

    $view_res ? [500, "Failed"] : [200, "OK"];
}

$SPEC{bencher_module_startup_overhead} = {
    v => 1.1,
    summary => 'Accept a list of module names and '.
        'perform startup overhead benchmark',
    description => <<'_',

    % bencher-module-startup-overhead Mod1 Mod2 Mod3

is basically a shortcut for creating a scenario like this:

    {
        module_startup => 1,
        participants => [
            {module=>"Mod1"},
            {module=>"Mod2"},
            {module=>"Mod3"},
        ],
    }

and running that scenario with `bencher`.

To specify import arguments, you can use:

    % bencher-module-startup-overhead Mod1 Mod2=arg1,arg2

which will translate to this Bencher scenario:

    {
        module_startup => 1,
        participants => [
            {module=>"Mod1"},
            {module=>"Mod2", import_args=>'arg1,arg2'},
        ],
    }


_
    args => {
        modules => {
            'x.name.is_plural' => 1,
            'x.name.singular' => 'module',
            schema => ['array*', of=>'perl::modargs*'],
            req => 1,
            pos => 0,
            greedy => 1,
            cmdline_src => 'stdin_or_args',
        },
        with_process_size => {
            schema => 'bool*',



( run in 2.662 seconds using v1.01-cache-2.11-cpan-df04353d9ac )