NAME

App::plackbench - programmatic interface to plackbench

See plackbench for the command line tool.

SYNOPSIS

    my $bench = App::plackbench->new(
        psgi_path => $psgi_path,
        count     => 5,
        uri       => '/some/path',
    );
    my $stats = $bench->run();

    printf("Averaged %8.3f seconds over %d requests\n", $stats->mean(), $stats->count());

DESCRIPTION

Class for executing requests on a Plack application and recording stats.

ATTRIBUTES

app

Defaults to a Plack app loaded from psgi_path, using "load_psgi" in Plack::Util.

count

Number of times to execute the request. Defaults to 1.

warm

If true, an initial request will be made which won't be included in the stats. Defaults to false.

fixup

An arrayref of subroutine references to do any preprocessing of the request. Each subroutine reference will be called in order (though you shouldn't rely on that) and passed a reference to the HTTP::Request object.

Each sub will be called once for every unique request. Under a normal GET request, there will only be one unique request. However if "post_data" is being used there will be one unique request for request body.

The return value from the subs is ignored.

post_data

An arrayref of request bodies. If set, POST requests will be made instead of GET requests.

If multiple request bodies are set they will be rotated through. This can be useful, for instance, to cycle through possible values for a field.

psgi_path

The path to the Plack application to be tested.

uri

The URI to request on the app.

CONSTRUCTOR

new(%attributes)

Returns a new instance of App::plackbench. Any arguments will be used a attribute settings.

METHODS

run()

Executes the requests (using the current attribute settings), and returns an App::plackbench::Stats object. Takes no arguments.

add_fixup_from_file($file)

Evaluates $file and appends the returned subroutine reference to "fixups". If the file can't be parsed, or if it doesn't return a subroutine reference the method will die.

GITHUB

https://github.com/pboyd/App-plackbench

AUTHOR

Paul Boyd <boyd.paul2@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Paul Boyd.

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

SEE ALSO

plackbench, Plack