From c8caedc6222e22420a4d7fd433a0cfc43fca3a3b Mon Sep 17 00:00:00 2001 From: "R. Tyler Ballance" Date: Mon, 12 Oct 2009 21:48:32 -0700 Subject: Swap out statprof for hotshot profiling with these basic Performance test cases --- cheetah/Tests/Performance.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cheetah/Tests/Performance.py b/cheetah/Tests/Performance.py index 0f7d613..213a02b 100644 --- a/cheetah/Tests/Performance.py +++ b/cheetah/Tests/Performance.py @@ -2,8 +2,9 @@ import Cheetah.NameMapper import Cheetah.Template -from Cheetah.Utils import statprof +import hotshot +import hotshot.stats import os import sys import unittest @@ -83,25 +84,25 @@ class DynamicTemplatePerformanceTest(unittest.TestCase): test_BasicDynamic = perftest(1200)(test_BasicDynamic) class PerformanceTest(unittest.TestCase): - iterations = 1000000 + iterations = 100000 display = False - def setUp(self): - super(PerformanceTest, self).setUp() - statprof.start() def runTest(self): + self.prof = hotshot.Profile('%s.prof' % self.__class__.__name__) + self.prof.start() for i in xrange(self.iterations): if hasattr(self, 'performanceSample'): self.display = True self.performanceSample() - - def tearDown(self): - super(PerformanceTest, self).tearDown() - statprof.stop() + self.prof.stop() + self.prof.close() if self.display: print '>>> %s (%d iterations) ' % (self.__class__.__name__, self.iterations) - statprof.display() + stats = hotshot.stats.load('%s.prof' % self.__class__.__name__) + stats.strip_dirs() + stats.sort_stats('time', 'calls') + stats.print_stats(40) class DynamicMethodCompilationTest(PerformanceTest): def performanceSample(self): -- cgit v1.2.1