L-shape calculation added.
[voro++.git] / trunk / examples / timing / timing_test.pl
blob85817d93b79585adadb55cdbdd59798dc3250336
1 #!/usr/bin/perl
3 # The range of grid sizes to consider
4 @range=(10..40);
6 # The number of trials to consider. If this is set to one, the time for a
7 # single trial will be outputted. For higher values, the mean of all the trials
8 # will be outputted, along with the standard deviation.
9 $tries=3;
11 # The flags to pass for code optimization
12 $opt="-O3";
14 foreach $r (@range) {
16 # Compile the code with the current grid size
17 system "g++-mp-4.8 $opt -I../../src -DNNN=$r -o timing_test "
18 ."-L../../src timing_test.cc";
20 # Carry out the trials for this grid size
21 $st=$stt=0;
22 foreach $t (1..$tries) {
24 # Run the code, and output the timing information to the
25 # "time_temp" file.
26 system "./timing_test >time_temp";
28 # Read the "time_temp" file to find the duration of the run
29 open F,"time_temp" or die "Can't open timing file: $!";
30 ($t)=split ' ',<F>;
31 $st+=$t;$stt+=$t*$t;
32 close F;
35 # Compute the mean and variance and print to standard output
36 $st/=$tries;
37 $stt=$stt/$tries-$st*$st;$stt=$stt>0?sqrt($stt):0;
38 print "$r $st $stt\n";
41 # Delete the temporary timing file
42 unlink "time_temp";