File: timing_test.pl

package info (click to toggle)
voro%2B%2B 0.4.6%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,372 kB
  • sloc: cpp: 6,384; perl: 232; makefile: 164
file content (42 lines) | stat: -rw-r--r-- 1,111 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl

# The range of grid sizes to consider
@range=(10..40);

# The number of trials to consider. If this is set to one, the time for a
# single trial will be outputted. For higher values, the mean of all the trials
# will be outputted, along with the standard deviation.
$tries=3;

# The flags to pass for code optimization 
$opt="-O3";

foreach $r (@range) {

	# Compile the code with the current grid size
	system "g++ $opt -I../../src -DNNN=$r -o timing_test "
		."-L../../src timing_test.cc -lvoro++";

	# Carry out the trials for this grid size
	$st=$stt=0;
	foreach $t (1..$tries) {

		# Run the code, and output the timing information to the
		# "time_temp" file.
		system "./timing_test >time_temp";

		# Read the "time_temp" file to find the duration of the run
		open F,"time_temp" or die "Can't open timing file: $!";
		($t)=split ' ',<F>;
		$st+=$t;$stt+=$t*$t;
		close F;
	}

	# Compute the mean and variance and print to standard output
	$st/=$tries;
	$stt=$stt/$tries-$st*$st;$stt=$stt>0?sqrt($stt):0;
	print "$r $st $stt\n";
}

# Delete the temporary timing file
unlink "time_temp";