The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

System::Index - A collection of three load-indexing functions for memory, CPU, and HD.

SYNOPSIS

        use System::Index;
        my $cpu_load = cpu_index();    # Averages 0.120 on my system, 'light' load
        my $mem_load = mem_index();    # Averages 0.88 on my system, 'light' load
        my $hd_load = hd_index();      # Averages 0.250 on my system, 'light' load
        

VERSION

This is Version 0.1 ($Id: System::Index.pm, v0.1 2000/04/09 12:27:05 josiah Exp $).

DESCRIPTION

This is a simple load-measure for memory, CPU, and hard-disk access. It requires Benchmark and Export. It measures the load with a simple timethis() benchmark loop with a few stat functions thrown in for good measure.

System::Index exports three functions by default to the callers namespace. These three functions are listed below.

Each of the functions take two optional parameters, $timelen and $debug (in that order).

$timelen specifies the length of the indexing loop in seconds. $timelen defaults to 2 seconds if $timelen is not given, or if it is 0.

$debug is a simple boolean flag to display the index counts for each internal index loop. $debug defaults to 0 if $debug is not given, or if it is 0.

FUNCTIONS

cpu_index($timelen, $debug);

Returns a decimal string with three significant digits after the decimal (remember sig-figs from highschool chemistry? :-) All three functions return the same format string.

This uses a simple inner loop of complex multiplication, division, and additions to measure the load of the CPU at that point in time. It measures the time it takes to complete the inner loop and stores this in an array. It repeats the inner loop until the total time of all the inner loops has taken more than $timelen. Then it averages the sum of the inner loops by the total time of all loops and returns that number through sprintf() to format the number.

mem_index($timelen, $debug);

This uses a simple inner loop of large array ( 777 x 777 ) creation and copying to index the load of the memory at that point in time. It measures the time it takes to complete the inner loop and stores this in an array. It repeats the inner loop until the total time of all the inner loops has taken more than $timelen. Then it averages the sum of the inner loops by the total time of all loops and returns that number through sprintf() to format the number.

hd_index($timelen, $debug, $file);

This uses a simple inner loop of simple file access by creating a file, writing 10 integers to the file, closing and re-opening, then deleting the file. This loop is used to index the load of the hard disk at that point in time. It measures the time it takes to complete the inner loop and stores this in an array. It repeats the inner loop until the total time of all the inner loops has taken more than $timelen. Then it averages the sum of the inner loops by the total time of all loops and returns that number through sprintf() to format the number.

This has a third optional parameter, $file. The default file name that hd_index() uses to index the HD with is '.hd_index.~$$'. If you wish to use another file name, you may pass the file name in the third argument to hd_index(). Remember, whatever file used is automatically removed with unlink() before returning.

BUGS

This is a beta release of System::Index, and that holding true, I am sure there are probably bugs in here which I just have not found yet. If you find bugs in this module, I would appreciate it greatly if you could report them to me at <jdb@wcoil.com>, or, even better, try to patch them yourself and figure out why the bug is being buggy, and send me the patched code, again at <jdb@wcoil.com>.

AUTHOR

Josiah Bryan <jdb@wcoil.com>

Copyright (c) 2000 Josiah Bryan. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

System::Index is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.

DOWNLOAD

You can always download the latest copy of System::Index from http://www.josiah.countystart.com/modules/get.pl?sysidx:pod

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 141:

'=item' outside of any '=over'

Around line 178:

You forgot a '=back' before '=head1'