Skip to content

Commit

Permalink
Update timing demo run scripts to print output in CSV format.
Browse files Browse the repository at this point in the history
  • Loading branch information
lebedov committed Mar 11, 2015
1 parent 668322d commit b633d5d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
26 changes: 20 additions & 6 deletions examples/timing/run.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
#!/usr/bin/env python

"""
Run timing test
Run timing test (non-GPU).
"""

import numpy as np

import csv
import re
import subprocess
import sys

script_name = 'timing_demo.py'

for spikes in xrange(100, 1100, 100):
out = subprocess.check_output(['python', script_name,
'-u', '2', '-s', str(spikes), '-g', '0', '-m', '1000'])
throughput, runtime = out.strip().split(',')
print spikes, throughput, runtime
w = csv.writer(sys.stdout)
for spikes in np.linspace(100, 10000, 10, dtype=int):
average_throughput_list = []
total_throughput_list = []
runtime_list = []
for i in xrange(3):
out = subprocess.check_output(['python', script_name,
'-u', '2', '-s', str(spikes), '-g', '0', '-m', '500'])
average_throughput, total_throughput, runtime = out.strip('()\n\"').split(', ')
average_throughput_list.append(float(average_throughput))
total_throughput_list.append(float(total_throughput))
runtime_list.append(float(runtime))
w.writerow([spikes, np.average(average_throughput_list),
np.average(total_throughput_list),
np.average(runtime_list)])
26 changes: 20 additions & 6 deletions examples/timing/run_gpu.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
#!/usr/bin/env python

"""
Run timing test
Run timing test (GPU).
"""

import numpy as np

import csv
import re
import subprocess
import sys

script_name = 'timing_demo_gpu.py'

for spikes in xrange(100, 1100, 100):
out = subprocess.check_output(['python', script_name,
'-u', '2', '-s', str(spikes), '-g', '0', '-m', '1000'])
throughput, runtime = out.strip().split(',')
print spikes, throughput, runtime
w = csv.writer(sys.stdout)
for spikes in np.linspace(100, 10000, 10, dtype=int):
average_throughput_list = []
total_throughput_list = []
runtime_list = []
for i in xrange(3):
out = subprocess.check_output(['python', script_name,
'-u', '2', '-s', str(spikes), '-g', '0', '-m', '500'])
average_throughput, total_throughput, runtime = out.strip('()\n\"').split(', ')
average_throughput_list.append(float(average_throughput))
total_throughput_list.append(float(total_throughput))
runtime_list.append(float(runtime))
w.writerow([spikes, np.average(average_throughput_list),
np.average(total_throughput_list),
np.average(runtime_list)])

0 comments on commit b633d5d

Please sign in to comment.