aboutsummaryrefslogtreecommitdiff
path: root/TestProfile.py
diff options
context:
space:
mode:
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())