NAME
HTTP::LoadGen::ScoreBoard - a slightly specialized IPC::ScoreBoard
SYNOPSIS
use HTTP::LoadGen::ScoreBoard;
# create it, storing the return value is optional. It is saved in
# in a global variable internally.
$sb=HTTP::LoadGen::ScoreBoard::init $name, $nproc, $slotsz, $extra;
# get/set the internal scoreboard
$sb=HTTP::LoadGen::ScoreBoard::scoreboard;
HTTP::LoadGen::ScoreBoard::scoreboard=$sb;
# get/set the current process' slot number
$procnr=HTTP::LoadGen::ScoreBoard::slot;
HTTP::LoadGen::ScoreBoard::slot=$procnr;
# signal that a new thread has been born
HTTP::LoadGen::ScoreBoard::thread_start;
# signal that a thread has finished
HTTP::LoadGen::ScoreBoard::thread_done;
# signal that a request has been started
HTTP::LoadGen::ScoreBoard::req_start;
# signal that a request has finished
HTTP::LoadGen::ScoreBoard::req_done $success, \%hdr, $body;
# get current thread count
$count=HTTP::LoadGen::ScoreBoard::thread_count;
# get number of started requests so far
$count=HTTP::LoadGen::ScoreBoard::req_started;
# get number of successfully finished requests so far
$count=HTTP::LoadGen::ScoreBoard::req_success;
# get number of failed requests so far
$count=HTTP::LoadGen::ScoreBoard::req_failed;
# get number of bytes transferred so far as HTTP header fields
$count=HTTP::LoadGen::ScoreBoard::header_bytes;
# get number of HTTP header fields transferred so far
$count=HTTP::LoadGen::ScoreBoard::header_count;
# get number of bytes transferred so far as HTTP body
$count=HTTP::LoadGen::ScoreBoard::body_bytes;
DESCRIPTION
This module is designed to cooperate with HTTP::LoadGen.
Functions
$sb=HTTP::LoadGen::ScoreBoard::init $name, $nproc, $slotsz, $extra
creates an IPC::ScoreBoard with $nproc
slots. The scoreboard has room at least for the values maintained by this module. If $slotsz
and $extra
are omitted or 0
a scoreboard of exactly that size is created. If you want to store more data you can either create a second scoreboard and waste a bit of memory or extend this one. To do that pass $slotsz
and $extra
as you need, see IPC::ScoreBoard. The fields private to HTTP::LoadGen::ScoreBoard
are placed at the end of each slot including the extra slot. So, custom elements are addressed as usual. For example
HTTP::LoadGen::ScoreBoard::init undef, $nproc, 5, 10;
creates a scoreboard with room for 5
custom values per slot and 10
custom values in the extra slot. The custom values are addressed by element indices from 0
to 4
and for the extra slot from 0
to 10
.
The fields private to this module are addressed by element indices from 5
and 10
for the extra slot upwards.
init
returns the scoreboard object. However, you don't need to store it because it is stored internally and can be accessed by the scoreboard
function.
The $name
parameter may be undef
to create an anonymous scoreboard or contain a file name for a named one.
$sb=HTTP::LoadGen::ScoreBoard::sbinit
sbinit
is an alias for init
that is exported on demand while init
is not.
$sb=HTTP::LoadGen::ScoreBoard::scoreboard
returns the scoreboard recently created by init
.
This is a lvalue-function. Hence, it can be assigned:
HTTP::LoadGen::ScoreBoard::scoreboard=$other_scoreboard;
undef HTTP::LoadGen::ScoreBoard::scoreboard;
HTTP::LoadGen::ScoreBoard::slot=$procnr;
This scoreboard maintains one slot per process. Hence, the slot number may be stored in a global variable. This lvalue-function provides access to that internal value.
This function must be called to set the process number prior to all other operations that access a certain slot, e.g. thread_start
, req_done
, etc.
HTTP::LoadGen::ScoreBoard::thread_start;
signals that a new thread has been born.
HTTP::LoadGen::ScoreBoard::thread_done;
signals that a thread has been done.
HTTP::LoadGen::ScoreBoard::req_start;
signals that a new request has been started.
HTTP::LoadGen::ScoreBoard::req_done $success, \%hdr, $body;
signals that a request has been done.
$success
is a boolean specifying whether the request was successful.
%hdr
is a hash containing all HTTP headers. Since a header can be multi-valued the values in this hash are expected to be arrays:
(
HEADER1=>[VALUE1, VALUE2, ...],
HEADER2=>[VALUE1, VALUE2, ...],
...
)
$body
is the HTTP response body.
$count=HTTP::LoadGen::ScoreBoard::thread_count;
returns the number of threads currently active over all processes.
$count=HTTP::LoadGen::ScoreBoard::req_started;
returns the number of requests that have been started by all processes together.
$count=HTTP::LoadGen::ScoreBoard::req_success;
returns the number of requests that have been successfully done by all processes together.
$count=HTTP::LoadGen::ScoreBoard::req_failed;
returns the number of requests that have failed over all processes.
Note, req_started - req_success - req_failed
is the number of requests currently in progress.
$count=HTTP::LoadGen::ScoreBoard::header_bytes;
returns the number of bytes received so far as HTTP header (excluding line endings and the HTTP status line).
$count=HTTP::LoadGen::ScoreBoard::header_count;
the number of HTTP header fields received so far. If a certain response contains a header with the same name multiple times it is counted only once.
$count=HTTP::LoadGen::ScoreBoard::body_bytes;
returns the number of bytes received so far as HTTP content.
EXPORT
exports on demand scoreboard
, slot
, thread_start
, thread_done
, req_start
, req_done
, thread_count
, req_started
, req_success
, req_failed
, header_bytes
, header_count
, body_bytes
and sbinit
SEE ALSO
AUTHOR
Torsten Förtsch, <torsten.foertsch@gmx.net>
COPYRIGHT AND LICENSE
Copyright (C) 2010 by Torsten Förtsch
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.