Created
June 21, 2009 02:25
-
-
Save rtyler/133364 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PerformanceTest(unittest.TestCase): | |
| iterations = 10000 | |
| display = False | |
| def setUp(self): | |
| super(PerformanceTest, self).setUp() | |
| statprof.start() | |
| def runTest(self): | |
| for i in xrange(self.iterations): | |
| if hasattr(self, 'performanceSample'): | |
| self.display = True | |
| self.performanceSample() | |
| def tearDown(self): | |
| super(PerformanceTest, self).tearDown() | |
| statprof.stop() | |
| if self.display: | |
| print '>>> %s (%d iterations) ' % (self.__class__.__name__, | |
| self.iterations) | |
| statprof.display() | |
| class DynamicCompilationTest(PerformanceTest): | |
| iterations = 1000000 | |
| def performanceSample(self): | |
| template = ''' | |
| #import sys | |
| #import os | |
| #def testMethod() | |
| #set foo = [1, 2, 3, 4] | |
| #return $foo[0] | |
| #end def | |
| ''' | |
| template = Cheetah.Template.Template.compile(template, | |
| keepRefToGeneratedCode=False) | |
| template = template() | |
| value = template.testMethod() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> DynamicCompilationTest (1000000 iterations) | |
| % cumulative self | |
| time seconds seconds name | |
| 50.82 93.64 74.99 Template.py:1017:__init__ | |
| 19.71 35.13 29.08 Template.py:334:compile | |
| 7.80 13.93 11.51 Template.py:1413:_initCheetahInstance | |
| 3.69 11.84 5.44 DynamicallyCompiledCheetahTemplate.py:66:testMethod | |
| 3.60 5.31 5.31 VerifyType.py:40:VerifyType | |
| 3.09 4.56 4.56 DummyTransaction.py:64:__init__ | |
| 1.93 96.48 2.85 DynamicallyCompiledCheetahTemplate.py:55:__init__ | |
| 1.88 146.23 2.77 Performance.py:107:performanceSample | |
| 1.10 2.24 1.62 VerifyType.py:56:VerifyTypeClass | |
| 1.08 1.60 1.60 Indenter.py:95:__init__ | |
| 1.08 1.60 1.60 Template.py:121:valOrDefault | |
| 0.93 1.38 1.38 Servlet.py:51:__init__ | |
| 0.90 147.56 1.33 Performance.py:91:runTest | |
| 0.76 1.84 1.12 DummyTransaction.py:67:response | |
| 0.55 0.82 0.82 Filters.py:17:__init__ | |
| 0.49 0.72 0.72 DummyTransaction.py:22:__init__ | |
| 0.34 0.50 0.50 Template.py:330:_getCompilerSettings | |
| 0.24 0.35 0.35 Template.py:326:_getCompilerClass | |
| 0.01 0.02 0.02 Parser.py:666:matchDirectiveName | |
| 0.00 147.56 0.00 unittest.py:420:run | |
| 0.00 147.56 0.00 unittest.py:692:run | |
| 0.00 147.56 0.00 unittest.py:743:__init__ | |
| 0.00 147.56 0.00 Performance.py:3:? | |
| 0.00 147.56 0.00 unittest.py:280:__call__ | |
| 0.00 147.56 0.00 unittest.py:245:run | |
| 0.00 147.56 0.00 unittest.py:793:runTests | |
| 0.00 147.56 0.00 unittest.py:427:__call__ | |
| 0.00 0.02 0.00 Parser.py:1436:parse | |
| 0.00 0.02 0.00 Compiler.py:1665:compile | |
| 0.00 0.02 0.00 Parser.py:655:matchDirective | |
| --- | |
| Sample count: 9219 | |
| Total time: 147.560000 seconds | |
| ... | |
| ---------------------------------------------------------------------- | |
| Ran 3 tests in 148.537s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment