Simulation::DiscreteEvent::NumericState - Moose role for recording statistics about server load
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;
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.
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.
Allows to set/get server state. Automatically updates statistic data.
Increases state by 1. Returns result state.
Decreases state by 1. Returns result state.
Returns server average load
Pavel Shaydo, <zwon at cpan.org>
<zwon at cpan.org>
Please see documentation for Simulation::DiscreteEvent
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.
To install Simulation::DiscreteEvent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Simulation::DiscreteEvent
CPAN shell
perl -MCPAN -e shell install Simulation::DiscreteEvent
For more information on module installation, please visit the detailed CPAN module installation guide.