Add display of min and max samples to Stopwatch's string representation.

llvm-svn: 143087
This commit is contained in:
Johnny Chen 2011-10-27 00:32:03 +00:00
parent d24e7e1d9b
commit 09e87a6622
2 changed files with 24 additions and 3 deletions

View File

@ -39,3 +39,13 @@ lldb frame variable benchmark: Avg: 1.615647 (Laps: 20, Total Elapsed Time: 32.3
lldb stepping benchmark: Avg: 0.138386 (Laps: 50, Total Elapsed Time: 6.919313)
lldb expr cmd benchmark: Avg: 0.218967 (Laps: 25, Total Elapsed Time: 5.474171)
lldb disassembly benchmark: Avg: 0.092677 (Laps: 10, Total Elapsed Time: 0.926766)
# With patch to lldbbench.py to display min and max of samples.
[17:27:09] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:'
lldb startup delay (create fresh target) benchmark: Avg: 0.103625 (Laps: 30, Total Elapsed Time: 3.108748, min=0.101225, max=0.136308)
lldb startup delay (set first breakpoint) benchmark: Avg: 0.102321 (Laps: 30, Total Elapsed Time: 3.069623, min=0.101270, max=0.102824)
lldb startup delay (run to breakpoint) benchmark: Avg: 0.445943 (Laps: 30, Total Elapsed Time: 13.378290, min=0.438535, max=0.475691)
lldb frame variable benchmark: Avg: 1.612034 (Laps: 20, Total Elapsed Time: 32.240689, min=1.591328, max=1.649720)
lldb stepping benchmark: Avg: 0.155064 (Laps: 50, Total Elapsed Time: 7.753182, min=0.101287, max=2.028978)
lldb expr cmd benchmark: Avg: 0.206160 (Laps: 25, Total Elapsed Time: 5.154005, min=0.203282, max=0.224982)
lldb disassembly benchmark: Avg: 0.032946 (Laps: 10, Total Elapsed Time: 0.329464, min=0.031380, max=0.039198)

View File

@ -1,4 +1,5 @@
import time
#import numpy
from lldbtest import *
class Stopwatch(object):
@ -48,6 +49,7 @@ class Stopwatch(object):
self.__start__ = None
self.__stop__ = None
self.__elapsed__ = 0.0
self.__nums__ = []
def __init__(self):
self.reset()
@ -66,6 +68,7 @@ class Stopwatch(object):
elapsed = self.__stop__ - self.__start__
self.__total_elapsed__ += elapsed
self.__laps__ += 1
self.__nums__.append(elapsed)
self.__start__ = None # Reset __start__ to be None again.
else:
raise Exception("stop() called without first start()?")
@ -78,10 +81,18 @@ class Stopwatch(object):
"""Equal to total elapsed time divided by the number of laps."""
return self.__total_elapsed__ / self.__laps__
#def sigma(self):
# """Return the standard deviation of the available samples."""
# if self.__laps__ <= 0:
# return None
# return numpy.std(self.__nums__)
def __str__(self):
return "Avg: %f (Laps: %d, Total Elapsed Time: %f)" % (self.avg(),
self.__laps__,
self.__total_elapsed__)
return "Avg: %f (Laps: %d, Total Elapsed Time: %f, min=%f, max=%f)" % (self.avg(),
self.__laps__,
self.__total_elapsed__,
min(self.__nums__),
max(self.__nums__))
class BenchBase(TestBase):
"""