aboutsummaryrefslogtreecommitdiff
path: root/TestProfile.py
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2011-01-10 23:28:01 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2011-01-10 23:28:01 -0500
commitd9747bd0c2598a06baeaf16dca8ff3b6469d4613 (patch)
tree23558d46c912520279a845356596294158b93458 /TestProfile.py
parenta1969e4c4bf61bc6e73c6a59fbef96e8ce361611 (diff)
parentbb1d982669c44a990ffc926f4666b6aa72237619 (diff)
Merge branch 'stability' of github.com:rcoh/SmootLight
Conflicts: LightInstallation.py TestProfile.py behaviors/DebugBehavior.py
Diffstat (limited to 'TestProfile.py')
-rw-r--r--TestProfile.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/TestProfile.py b/TestProfile.py
index 663e57b..f25a63d 100644
--- a/TestProfile.py
+++ b/TestProfile.py
@@ -1,6 +1,7 @@
import cProfile
import struct
import random
+import scipy.weave as weave
import math
#from LightInstallation import main
numiter = 1000000
@@ -56,9 +57,34 @@ def expapprox():
for i in xrange(0, numiter):
a = 1+-1+(-1)**2/float(2)
print a
-command = """exptest()"""
+
+def normal_python():
+ for i in xrange(0,numiter):
+ a = math.sqrt(3 + 4 + 5)
+
+def weave_outloop():
+ code = """
+ float x = 0;
+ for (int i = 0;i < numiter;i++) {
+ x = sqrt(3 + 4 + 5);
+ }
+ """
+ weave.inline(code, ['numiter'])
+
+def weave_inloop():
+ code = """
+ x = sqrt(3 + 4 + 5);
+ """
+ x = 0.0
+ for i in xrange(0,numiter):
+ weave.inline(code, ['x'])
+
+command = """normal_python()"""
+cProfile.runctx(command, globals(), locals())
+
+command = """weave_outloop()"""
cProfile.runctx(command, globals(), locals())
-command = """expapprox()"""
+command = """weave_inloop()"""
cProfile.runctx(command, globals(), locals())