added dgrid bench script, also ignored another couple of directories
This commit is contained in:
parent
f6c7481042
commit
d001719447
@ -4,3 +4,5 @@
|
|||||||
^smbinterp.egg-info$
|
^smbinterp.egg-info$
|
||||||
^lib$
|
^lib$
|
||||||
^profiles$
|
^profiles$
|
||||||
|
^meshes$
|
||||||
|
^data$
|
||||||
|
48
bin/dgrid_bench.py
Normal file
48
bin/dgrid_bench.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import pickle
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
import interp.bootstrap
|
||||||
|
from interp.grid.delaunay import dgrid
|
||||||
|
from interp.tools import improved_answer, friendly_exact_3D as exact
|
||||||
|
|
||||||
|
|
||||||
|
def test_success(rcount, count):
|
||||||
|
v = np.random.random((rcount, 3)) * 10
|
||||||
|
pickle.dump(v, open('/tmp/v.p', 'w'))
|
||||||
|
q = np.array([exact(x) for x in v])
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
g = dgrid(v,q)
|
||||||
|
end = time.time()
|
||||||
|
|
||||||
|
print "cells: %d, verts: %d" % (len(g.cells), len(g.verts))
|
||||||
|
print end - start, " seconds to instantiate the dgrid object"
|
||||||
|
|
||||||
|
results = {True:0, False:0}
|
||||||
|
i = 0
|
||||||
|
outside = 0
|
||||||
|
while i < count:
|
||||||
|
try:
|
||||||
|
X = np.random.random((1,3))[0]
|
||||||
|
|
||||||
|
a = g.run_baker(X, order = 3, extra_points = 32)
|
||||||
|
e = exact(X)
|
||||||
|
|
||||||
|
results[improved_answer(a, e)] += 1
|
||||||
|
i += 1
|
||||||
|
except Exception as e:
|
||||||
|
outside += 1
|
||||||
|
|
||||||
|
print "total skipped points: %d" % outside
|
||||||
|
return results
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print >> sys.stderr, "usage: %s <number of random points> <number of attempted interps>" % sys.argv[0]
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
rcount, count = (int(i) for i in sys.argv[1:])
|
||||||
|
print test_success(rcount, int(count))
|
Loading…
Reference in New Issue
Block a user