Skip to content

Commit 9d17c94

Browse files
committed
timing statistics
1 parent cf0a3f1 commit 9d17c94

File tree

3 files changed

+160
-0
lines changed

3 files changed

+160
-0
lines changed

makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
clean:
2+
rm -f *.pyc *~ temp.csv
3+
test:
4+
echo "Test takes 30 minutes..."
5+
python timing.py
6+
release: clean
7+
cd ..; tar -zcvf pysrim.tgz pysrim; mv pysrim.tgz pysrim/.

makefile~

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
clean:
2+
rm -f *.pyc *~ temp.csv
3+
test:
4+
echo "Test takes 30 minutes..."
5+
python timing.py
6+
release:
7+
cd ..; tar -zcvf pysrim.tgz pysrim; mv pysrim.tgz pysrim/.

timing.py

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import time
2+
import subprocess
3+
import matplotlib as mpl
4+
mpl.use('Agg')
5+
import matplotlib.pyplot as plt
6+
from numpy import polyfit, poly1d
7+
import numpy as np
8+
9+
# Running Timing for different number of processors
10+
maxNumProcessors = 4
11+
12+
numCores = []
13+
runTimes = []
14+
15+
numIons = 100
16+
ionEnergy = 100000.0
17+
elementIon = 'Fe'
18+
19+
multipleSamples = 10
20+
21+
for i in range(maxNumProcessors):
22+
for j in range(multipleSamples):
23+
start_time = time.time()
24+
25+
args = ['mpirun', '-n', str(i+1),
26+
'python', 'pysrim.py',
27+
'--numIons', str(numIons),
28+
'--ionEnergy', str(ionEnergy),
29+
'--elementIon', str(elementIon),
30+
'-o', 'temp.csv']
31+
32+
proc = subprocess.call(args)
33+
34+
runTime = time.time() - start_time
35+
36+
numCores.append(i+1)
37+
runTimes.append(runTime)
38+
39+
fig, ax = plt.subplots()
40+
41+
ax.set_xlabel('Number of Cores')
42+
ax.set_ylabel('Run Time [seconds]')
43+
ax.plot(numCores, runTimes, 'bo')
44+
45+
fig.suptitle('Number of Cores vs. Runtime')
46+
x = [1,2,3,4]
47+
y = [sum(runTimes[0:9]) / 10, sum(runTimes[10:19]) / 10, sum(runTimes[20:29]) / 10, sum(runTimes[30:39])/ 10]
48+
49+
ax.plot(x, y, 'r--')
50+
51+
fig.savefig('numcores.svg')
52+
53+
# Running Timing for different number of ions
54+
maxNumIons = 400
55+
56+
numIons = []
57+
runTimes = []
58+
averageRunTimes = []
59+
60+
numCores = 4
61+
ionEnergy = 100000.0
62+
elementIon = 'Fe'
63+
64+
numSamples = 10
65+
66+
for i in range(10, maxNumIons, 50):
67+
averageRunTime = 0.0
68+
for j in range(numSamples):
69+
start_time = time.time()
70+
71+
args = ['mpirun', '-n', str(numCores),
72+
'python', 'pysrim.py',
73+
'--numIons', str(i),
74+
'--ionEnergy', str(ionEnergy),
75+
'--elementIon', str(elementIon),
76+
'-o', 'temp.csv']
77+
78+
proc = subprocess.call(args)
79+
80+
runTime = time.time() - start_time
81+
82+
averageRunTime += runTime
83+
84+
numIons.append(i+1)
85+
runTimes.append(runTime)
86+
87+
averageRunTimes.append(averageRunTime / numSamples)
88+
89+
fig, ax = plt.subplots()
90+
91+
ax.set_xlabel('Number of Ions')
92+
ax.set_ylabel('Run Time [seconds]')
93+
fig.suptitle('Number of Ions vs. Runtime')
94+
95+
ax.plot(numIons, runTimes, 'bo')
96+
ax.plot(range(0, maxNumIons, 50), averageRunTimes, 'r--')
97+
98+
fig.savefig('numions.svg')
99+
100+
101+
# Running Timing for different ion energies
102+
maxIonEnergy = 1000000
103+
104+
ionEnergies = []
105+
runTimes = []
106+
averageRunTimes = []
107+
108+
numCores = 4
109+
numIons = 100
110+
elementIon = 'Fe'
111+
112+
numSamples = 5
113+
114+
for i in range(10, maxIonEnergy, 100000):
115+
averageRunTime = 0.0
116+
for j in range(numSamples):
117+
start_time = time.time()
118+
119+
args = ['mpirun', '-n', str(numCores),
120+
'python', 'pysrim.py',
121+
'--numIons', str(numIons),
122+
'--ionEnergy', str(i),
123+
'--elementIon', str(elementIon),
124+
'-o', 'temp.csv']
125+
126+
proc = subprocess.call(args)
127+
128+
runTime = time.time() - start_time
129+
130+
averageRunTime += runTime
131+
132+
ionEnergies.append(i)
133+
runTimes.append(runTime)
134+
135+
averageRunTimes.append(averageRunTime / numSamples)
136+
137+
fig, ax = plt.subplots()
138+
139+
ax.set_xlabel('Ion Energy')
140+
ax.set_ylabel('Run Time [seconds]')
141+
fig.suptitle('Ions Energy vs. Runtime')
142+
143+
ax.plot(ionEnergies, runTimes, 'bo')
144+
ax.plot(range(10, maxIonEnergy, 100000), averageRunTimes, 'r--')
145+
146+
fig.savefig('ionenergies.svg')

0 commit comments

Comments
 (0)