Benchmark::Object - Simple interface to do benchmarking.
=head1 SYNOPSIS
use Benchmark::Object;
print "Benchmarking for loop runs 2000 times.\n";
#Sart benchmarking here
my $obj = Benchmark::Object->start();
for(my $i = 0; $i < 2000; $i++) {
}
#First pause
$obj->pause();
print "Benchmarking for loop runs 1000 times.\n";
#First resume
$obj->resume();
for(my $i = 0; $i < 1000; $i++) {
}
#Second pause
$obj->pause();
print "Benchmarking for loop runs 500 times.\n";
#Second resume
$obj->resume();
for(my $i = 0; $i < 1000; $i++) {
}
#Final stop of benchmarking
$obj->stop();
#Print total result in tabluar form
$obj->print_benchmark();
#Get benchmark result on return hash form
my $ret = $obj->get_benchmark();
require Data::Dumper;
print Data::Dumper::Dumper($ret);
=head1 DESCRIPTION
This is a simple benchmarking module, can be used to get the banchmark at any part of code or complete code.
There are four functions (start(it is also constructor), pause, resume, stop) in this module to perform benchmarking. It is recommended to use these functions in logical order. otherwise total benchmarking result will be having incorrect value.
There are two fundtions, (print_benchmark and get_benchmark) to get result of benchmark.
=over 4
=item start
This function will start benchmarking.
=item pause
This function will pause benchmarking. Should be called after start or resume.
=item resume
This function will resume benchmarking, which was paused earlier using pause() function. Should be called after pause.
=item stop
This function will stop benchmarking. Should be called after start or resume.
=item print_benchmark
This function will print benchmark result in tablur form. Below is example:
Start Datetime: Oct 14 2013 15:27:36
End Datetime: Oct 14 2013 15:27:36
Iteration Second Microsecond Total in Microseconds