Strip extra spaces from code.
[voro++.git] / branches / dynamic / examples / timing / timing_test.pl
blobe743195596a3e738d372d51b774cbbfed2a0f73a
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
7 # for a single trial will be outputted. For higher values, the mean
8 # of all the trials will be outputted, along with the standard
9 # deviation.
10 $tries=1;
12 # The flags to pass for code optimization. The second line is appropriate for
13 # Mac OS X, forcing more function inlining, and enabling the Apple-only "-fast"
14 # flag for maximum code optimization.
15 $opt="-O3";
16 #$opt+="-fast --param large-function-growth=1000 --param max-inline-insns-single=2000";
18 foreach $r (@range) {
20 # Compile the code with the current grid size
21 system "g++ -I../../src -DNNN=$r -o timing_test $opt timing_test.cc";
23 # Carry out the trials for this grid size
24 $st=$stt=0;
25 foreach $t (1..$tries) {
27 # Run the code, and output the timing information to the
28 # "time_temp" file.
29 system "./timing_test >time_temp";
31 # Read the "time_temp" file to find the duration of the run
32 open F,"time_temp" or die "Can't open timing file: $!";
33 ($t)=split ' ',<F>;
34 $st+=$t;$stt+=$t*$t;
35 close F;
38 # Compute the mean and variance and print to standard output
39 $st/=$tries;
40 $stt=$stt/$tries-$st*$st;$stt=$stt>0?sqrt($stt):0;
41 print "$r $st $stt\n";
44 # Delete the temporary timing file
45 system "rm time_temp";