Strip extra spaces from code.
[voro++.git] / branches / 2d / examples / timing / timing_test_2d.pl
blobbd1a449a160fda44f0700e9168acc4a7042ce4ee
1 #!/usr/bin/perl
3 # The range of grid sizes to consider
4 @range=(10..80);
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=20;
11 # The flags to pass for code optimization
12 $opt="-O3";
14 foreach $r (@range) {
15 $r*=2;
17 # Compile the code with the current grid size
18 system "g++ $opt -I../../src -DNNN=$r -o timing_test_2d "
19 ."-L../../src timing_test_2d.cc -lvoro++_2d";
21 # Carry out the trials for this grid size
22 $st=$stt=0;
23 foreach $t (1..$tries) {
25 # Run the code, and output the timing information to the
26 # "time_temp" file.
27 system "./timing_test_2d >time_temp_2d";
29 # Read the "time_temp" file to find the duration of the run
30 open F,"time_temp_2d" or die "Can't open timing file: $!";
31 ($t)=split ' ',<F>;
32 $st+=$t;$stt+=$t*$t;
33 close F;
36 # Compute the mean and variance and print to standard output
37 $st/=$tries;
38 $stt=$stt/$tries-$st*$st;$stt=$stt>0?sqrt($stt):0;
39 print "$r $st $stt\n";
42 # Delete the temporary timing file
43 unlink "time_temp_2d";