Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
Numbers.CompareLongs Class Reference
Inheritance diagram for Numbers.CompareLongs:
Inheritance graph
[legend]
Collaboration diagram for Numbers.CompareLongs:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test
def calibrate
def get_timer
def compatible
def calibrate_test
def run
def stat

Public Attributes

 last_timing
 warp
 times

Static Public Attributes

float version = 2.0
 Instance variables that each test should override.
int operations = 30
int rounds = 70000
int is_a_test = 1
 Internal variables.
tuple last_timing = (0.0, 0.0, 0.0)
int warp = 1
 calibration_runs = CALIBRATION_RUNS
 overhead_times = None
list times = []
 timer = TIMER_PLATFORM_DEFAULT

Detailed Description

Definition at line 591 of file Numbers.py.


Member Function Documentation

Calibrate the test.

    This method should execute everything that is needed to
    setup and run the test - except for the actual operations
    that you intend to measure. pybench uses this method to
    measure the test implementation overhead.

Reimplemented from pybench.Test.

Definition at line 781 of file Numbers.py.

00781 
00782     def calibrate(self):
00783 
00784         for i in range(self.rounds):
00785             pass

Here is the caller graph for this function:

def pybench.Test.calibrate_test (   self) [inherited]

Definition at line 262 of file pybench.py.

00262 
00263     def calibrate_test(self):
00264 
00265         if self.calibration_runs == 0:
00266             self.overhead_times = [0.0]
00267             return
00268 
00269         calibrate = self.calibrate
00270         timer = self.get_timer()
00271         calibration_loops = range(CALIBRATION_LOOPS)
00272 
00273         # Time the calibration loop overhead
00274         prep_times = []
00275         for i in range(self.calibration_runs):
00276             t = timer()
00277             for i in calibration_loops:
00278                 pass
00279             t = timer() - t
00280             prep_times.append(t / CALIBRATION_LOOPS)
00281         min_prep_time = min(prep_times)
00282         if _debug:
00283             print()
00284             print('Calib. prep time     = %.6fms' % (
00285                 min_prep_time * MILLI_SECONDS))
00286 
00287         # Time the calibration runs (doing CALIBRATION_LOOPS loops of
00288         # .calibrate() method calls each)
00289         for i in range(self.calibration_runs):
00290             t = timer()
00291             for i in calibration_loops:
00292                 calibrate()
00293             t = timer() - t
00294             self.overhead_times.append(t / CALIBRATION_LOOPS
00295                                        - min_prep_time)
00296 
00297         # Check the measured times
00298         min_overhead = min(self.overhead_times)
00299         max_overhead = max(self.overhead_times)
00300         if _debug:
00301             print('Calib. overhead time = %.6fms' % (
00302                 min_overhead * MILLI_SECONDS))
00303         if min_overhead < 0.0:
00304             raise ValueError('calibration setup did not work')
00305         if max_overhead - min_overhead > 0.1:
00306             raise ValueError(
00307                 'overhead calibration timing range too inaccurate: '
00308                 '%r - %r' % (min_overhead, max_overhead))

def pybench.Test.compatible (   self,
  other 
) [inherited]
Return 1/0 depending on whether the test is compatible
    with the other Test instance or not.

Definition at line 250 of file pybench.py.

00250 
00251     def compatible(self, other):
00252 
00253         """ Return 1/0 depending on whether the test is compatible
00254             with the other Test instance or not.
00255 
00256         """
00257         if self.version != other.version:
00258             return 0
00259         if self.rounds != other.rounds:
00260             return 0
00261         return 1

Here is the caller graph for this function:

def pybench.Test.get_timer (   self) [inherited]
Return the timer function to use for the test.

Definition at line 243 of file pybench.py.

00243 
00244     def get_timer(self):
00245 
00246         """ Return the timer function to use for the test.
00247 
00248         """
00249         return get_timer(self.timer)

Here is the caller graph for this function:

def pybench.Test.run (   self) [inherited]
Run the test in two phases: first calibrate, then
    do the actual test. Be careful to keep the calibration
    timing low w/r to the test timing.

Definition at line 309 of file pybench.py.

00309 
00310     def run(self):
00311 
00312         """ Run the test in two phases: first calibrate, then
00313             do the actual test. Be careful to keep the calibration
00314             timing low w/r to the test timing.
00315 
00316         """
00317         test = self.test
00318         timer = self.get_timer()
00319 
00320         # Get calibration
00321         min_overhead = min(self.overhead_times)
00322 
00323         # Test run
00324         t = timer()
00325         test()
00326         t = timer() - t
00327         if t < MIN_TEST_RUNTIME:
00328             raise ValueError('warp factor too high: '
00329                              'test times are < 10ms')
00330         eff_time = t - min_overhead
00331         if eff_time < 0:
00332             raise ValueError('wrong calibration')
00333         self.last_timing = (eff_time, t, min_overhead)
00334         self.times.append(eff_time)

def pybench.Test.stat (   self) [inherited]
Return test run statistics as tuple:

    (minimum run time,
     average run time,
     total run time,
     average time per operation,
     minimum overhead time)

Definition at line 357 of file pybench.py.

00357 
00358     def stat(self):
00359 
00360         """ Return test run statistics as tuple:
00361 
00362             (minimum run time,
00363              average run time,
00364              total run time,
00365              average time per operation,
00366              minimum overhead time)
00367 
00368         """
00369         runs = len(self.times)
00370         if runs == 0:
00371             return 0.0, 0.0, 0.0, 0.0
00372         min_time = min(self.times)
00373         total_time = sum(self.times)
00374         avg_time = total_time / float(runs)
00375         operation_avg = total_time / float(runs
00376                                            * self.rounds
00377                                            * self.operations)
00378         if self.overhead_times:
00379             min_overhead = min(self.overhead_times)
00380         else:
00381             min_overhead = self.last_timing[2]
00382         return min_time, avg_time, total_time, operation_avg, min_overhead

Here is the call graph for this function:

def Numbers.CompareLongs.test (   self)
Run the test.

    The test needs to run self.rounds executing
    self.operations number of operations each.

Reimplemented from pybench.Test.

Definition at line 597 of file Numbers.py.

00597 
00598     def test(self):
00599 
00600         for i in range(self.rounds):
00601 
00602             1234567890 < 3456789012345
00603             1234567890 > 3456789012345
00604             1234567890 == 3456789012345
00605             1234567890 > 3456789012345
00606             1234567890 < 3456789012345
00607 
00608             1234567890 < 3456789012345
00609             1234567890 > 3456789012345
00610             1234567890 == 3456789012345
00611             1234567890 > 3456789012345
00612             1234567890 < 3456789012345
00613 
00614             1234567890 < 3456789012345
00615             1234567890 > 3456789012345
00616             1234567890 == 3456789012345
00617             1234567890 > 3456789012345
00618             1234567890 < 3456789012345
00619 
00620             1234567890 < 3456789012345
00621             1234567890 > 3456789012345
00622             1234567890 == 3456789012345
00623             1234567890 > 3456789012345
00624             1234567890 < 3456789012345
00625 
00626             1234567890 < 3456789012345
00627             1234567890 > 3456789012345
00628             1234567890 == 3456789012345
00629             1234567890 > 3456789012345
00630             1234567890 < 3456789012345
00631 
00632             1234567890 < 3456789012345
00633             1234567890 > 3456789012345
00634             1234567890 == 3456789012345
00635             1234567890 > 3456789012345
00636             1234567890 < 3456789012345
00637 
00638             1234567890 < 3456789012345
00639             1234567890 > 3456789012345
00640             1234567890 == 3456789012345
00641             1234567890 > 3456789012345
00642             1234567890 < 3456789012345
00643 
00644             1234567890 < 3456789012345
00645             1234567890 > 3456789012345
00646             1234567890 == 3456789012345
00647             1234567890 > 3456789012345
00648             1234567890 < 3456789012345
00649 
00650             1234567890 < 3456789012345
00651             1234567890 > 3456789012345
00652             1234567890 == 3456789012345
00653             1234567890 > 3456789012345
00654             1234567890 < 3456789012345
00655 
00656             1234567890 < 3456789012345
00657             1234567890 > 3456789012345
00658             1234567890 == 3456789012345
00659             1234567890 > 3456789012345
00660             1234567890 < 3456789012345
00661 
00662             1234567890 < 3456789012345
00663             1234567890 > 3456789012345
00664             1234567890 == 3456789012345
00665             1234567890 > 3456789012345
00666             1234567890 < 3456789012345
00667 
00668             1234567890 < 3456789012345
00669             1234567890 > 3456789012345
00670             1234567890 == 3456789012345
00671             1234567890 > 3456789012345
00672             1234567890 < 3456789012345
00673 
00674             1234567890 < 3456789012345
00675             1234567890 > 3456789012345
00676             1234567890 == 3456789012345
00677             1234567890 > 3456789012345
00678             1234567890 < 3456789012345
00679 
00680             1234567890 < 3456789012345
00681             1234567890 > 3456789012345
00682             1234567890 == 3456789012345
00683             1234567890 > 3456789012345
00684             1234567890 < 3456789012345
00685 
00686             1234567890 < 3456789012345
00687             1234567890 > 3456789012345
00688             1234567890 == 3456789012345
00689             1234567890 > 3456789012345
00690             1234567890 < 3456789012345
00691 
00692             1234567890 < 3456789012345
00693             1234567890 > 3456789012345
00694             1234567890 == 3456789012345
00695             1234567890 > 3456789012345
00696             1234567890 < 3456789012345
00697 
00698             1234567890 < 3456789012345
00699             1234567890 > 3456789012345
00700             1234567890 == 3456789012345
00701             1234567890 > 3456789012345
00702             1234567890 < 3456789012345
00703 
00704             1234567890 < 3456789012345
00705             1234567890 > 3456789012345
00706             1234567890 == 3456789012345
00707             1234567890 > 3456789012345
00708             1234567890 < 3456789012345
00709 
00710             1234567890 < 3456789012345
00711             1234567890 > 3456789012345
00712             1234567890 == 3456789012345
00713             1234567890 > 3456789012345
00714             1234567890 < 3456789012345
00715 
00716             1234567890 < 3456789012345
00717             1234567890 > 3456789012345
00718             1234567890 == 3456789012345
00719             1234567890 > 3456789012345
00720             1234567890 < 3456789012345
00721 
00722             1234567890 < 3456789012345
00723             1234567890 > 3456789012345
00724             1234567890 == 3456789012345
00725             1234567890 > 3456789012345
00726             1234567890 < 3456789012345
00727 
00728             1234567890 < 3456789012345
00729             1234567890 > 3456789012345
00730             1234567890 == 3456789012345
00731             1234567890 > 3456789012345
00732             1234567890 < 3456789012345
00733 
00734             1234567890 < 3456789012345
00735             1234567890 > 3456789012345
00736             1234567890 == 3456789012345
00737             1234567890 > 3456789012345
00738             1234567890 < 3456789012345
00739 
00740             1234567890 < 3456789012345
00741             1234567890 > 3456789012345
00742             1234567890 == 3456789012345
00743             1234567890 > 3456789012345
00744             1234567890 < 3456789012345
00745 
00746             1234567890 < 3456789012345
00747             1234567890 > 3456789012345
00748             1234567890 == 3456789012345
00749             1234567890 > 3456789012345
00750             1234567890 < 3456789012345
00751 
00752             1234567890 < 3456789012345
00753             1234567890 > 3456789012345
00754             1234567890 == 3456789012345
00755             1234567890 > 3456789012345
00756             1234567890 < 3456789012345
00757 
00758             1234567890 < 3456789012345
00759             1234567890 > 3456789012345
00760             1234567890 == 3456789012345
00761             1234567890 > 3456789012345
00762             1234567890 < 3456789012345
00763 
00764             1234567890 < 3456789012345
00765             1234567890 > 3456789012345
00766             1234567890 == 3456789012345
00767             1234567890 > 3456789012345
00768             1234567890 < 3456789012345
00769 
00770             1234567890 < 3456789012345
00771             1234567890 > 3456789012345
00772             1234567890 == 3456789012345
00773             1234567890 > 3456789012345
00774             1234567890 < 3456789012345
00775 
00776             1234567890 < 3456789012345
00777             1234567890 > 3456789012345
00778             1234567890 == 3456789012345
00779             1234567890 > 3456789012345
00780             1234567890 < 3456789012345

Here is the caller graph for this function:


Member Data Documentation

pybench.Test.calibration_runs = CALIBRATION_RUNS [static, inherited]

Definition at line 206 of file pybench.py.

int pybench.Test.is_a_test = 1 [static, inherited]

Internal variables.

Definition at line 197 of file pybench.py.

tuple pybench.Test.last_timing = (0.0, 0.0, 0.0) [static, inherited]

Definition at line 200 of file pybench.py.

Definition at line 332 of file pybench.py.

Reimplemented from pybench.Test.

Definition at line 594 of file Numbers.py.

pybench.Test.overhead_times = None [static, inherited]

Definition at line 209 of file pybench.py.

int Numbers.CompareLongs.rounds = 70000 [static]

Reimplemented from pybench.Test.

Definition at line 595 of file Numbers.py.

pybench.Test.timer = TIMER_PLATFORM_DEFAULT [static, inherited]

Definition at line 215 of file pybench.py.

list pybench.Test.times = [] [static, inherited]

Definition at line 212 of file pybench.py.

pybench.Test.times [inherited]

Definition at line 234 of file pybench.py.

float Numbers.CompareLongs.version = 2.0 [static]

Instance variables that each test should override.

Reimplemented from pybench.Test.

Definition at line 593 of file Numbers.py.

int pybench.Test.warp = 1 [static, inherited]

Definition at line 203 of file pybench.py.

pybench.Test.warp [inherited]

Definition at line 224 of file pybench.py.


The documentation for this class was generated from the following file: