X BOL wishing you a very and Happy New year

Alternative content

History

Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Benchmarking Perl Module !: Revision

The benchmark module is a great tool to know the time the code takes to run. The output is usually in terms of CPU time. This module provides us with a way to optimize our code. With the advent of petascale computing and other multicore processor it is becoming a neccesity to know about the CPU time taken by our perl program.

This is the simple way to use the module

Example1:

use Benchmark;

$first_time = Benchmark->new;

our code……

$second_time = Benchmark->new;

$final_difference = timediff($first_time,$second_time);

print “the code took, timestr($final_difference),”\n”;

that was a very simple way to know the time diff , we can use it to know the time taken by some part of the code in the program.

More sophisticated way:

use Benchmark;
sub first {

my(arguments) = @_;

}

timethese(100, { first => ‘first_sub(arguments)’});

The first argument to timethese is 100 (evaluate 100 times).

Hope this very small tutorial with Benchmark will help people get started.