Using Python with Numpy
System:
Code:
Ubuntu 12.04 32-bit
Kernel Linux 3.2.0-43-generic-pae
Memory 3.8 GiB
Processor Intel Core 2 Duo T9400 @ 2.53 GHz x 2
Code:
Code:
import sys
import numpy
import time
import scipy
import psutil
n_runs = 1000
print ""
print ""
print "Python version %s" % (sys.version)
print "Numpy version %s" % (numpy.__version__)
print "Scipy version %s" % (scipy.__version__)
print "Psutil version %s" % (psutil.__version__)
print ""
N = numpy.loadtxt(open('N.dat'))
d = numpy.loadtxt(open('d.dat'))
data = []
for i in range(1,n_runs+1):
start = time.time()
x = numpy.linalg.solve(N,d)
end = time.time()
row = [end - start]
row.extend(psutil.cpu_percent(interval=1,percpu=True))
s = "\t".join([str(item) for item in row])
data.append(s)
f = open('times.dat','w')
f.write("\n".join(data))
f.close()
x = numpy.linalg.solve(N,d)
print ", ".join([str(f) for f in x])
print ""
Average run time: 10.1 seconds
Standard Deviation: 5.1 seconds
The file output.txt contains versions and the solution for x.
The file runs.txt contains the run data. Note that I was doing work while letting this run in the backround, which skews the times. I collected CPU usage data to try and account for this; one interesting note is that there are two different clusters of execution times - I believe this is from my laptop throttling the CPU when I unplugged and was running off battery for a while (if you plot runs over time, you will see three distinct sections where the execution times are consistently higher).