NAME

Simulation::DiscreteEvent::NumericState - Moose role for recording statistics about server load

SYNOPSIS

Add Simulation::DiscreteEvent::NumericState role to your server:

package MyServer;
use Moose;
BEGIN { extends 'Simulation::DiscreteEvent::Server'; }
with 'Simulation::DiscreteEvent::NumericState';
sub handler1 : Event(start) {
    # handle start event here

    # set state
    $self->state(1);
}
sub handler2 : Event(stop) {
    # handle stop event here

    # set state
    $self->state(0);
}

Then after running simulation you can get information about state changes during simulation:

my @state_changes = $server->state_data;
my $average_load  = $server->average_load;

DESCRIPTION

This role allows you to record statistic information about server state during simulation. It also provides simple functions to get some summary of collected data.

METHODS

$self->state_data

Returns array with collected data. Each array item is reference to array with two elements - time of the state change and the new state value.

$self->state([$state])

Allows to set/get server state. Automatically updates statistic data.

$self->state_inc

Increases state by 1. Returns result state.

$self->state_dec

Decreases state by 1. Returns result state.

$self->average_load

Returns server average load

AUTHOR

Pavel Shaydo, <zwon at cpan.org>

SUPPORT

Please see documentation for Simulation::DiscreteEvent

LICENSE AND COPYRIGHT

Copyright 2010 Pavel Shaydo.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.