Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
Exceptions.TryExcept Class Reference
Inheritance diagram for Exceptions.TryExcept:
Inheritance graph
[legend]
Collaboration diagram for Exceptions.TryExcept:
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 = 15
int rounds = 150000
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 55 of file Exceptions.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 688 of file Exceptions.py.

00688 
00689     def calibrate(self):
00690 
00691         for i in range(self.rounds):
00692             pass

Here is the call graph for this function:

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 Exceptions.TryExcept.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 61 of file Exceptions.py.

00061 
00062     def test(self):
00063 
00064         for i in range(self.rounds):
00065             try:
00066                 pass
00067             except:
00068                 pass
00069             try:
00070                 pass
00071             except:
00072                 pass
00073             try:
00074                 pass
00075             except:
00076                 pass
00077             try:
00078                 pass
00079             except:
00080                 pass
00081             try:
00082                 pass
00083             except:
00084                 pass
00085             try:
00086                 pass
00087             except:
00088                 pass
00089             try:
00090                 pass
00091             except:
00092                 pass
00093             try:
00094                 pass
00095             except:
00096                 pass
00097             try:
00098                 pass
00099             except:
00100                 pass
00101             try:
00102                 pass
00103             except:
00104                 pass
00105 
00106             try:
00107                 pass
00108             except:
00109                 pass
00110             try:
00111                 pass
00112             except:
00113                 pass
00114             try:
00115                 pass
00116             except:
00117                 pass
00118             try:
00119                 pass
00120             except:
00121                 pass
00122             try:
00123                 pass
00124             except:
00125                 pass
00126             try:
00127                 pass
00128             except:
00129                 pass
00130             try:
00131                 pass
00132             except:
00133                 pass
00134             try:
00135                 pass
00136             except:
00137                 pass
00138             try:
00139                 pass
00140             except:
00141                 pass
00142             try:
00143                 pass
00144             except:
00145                 pass
00146 
00147 
00148             try:
00149                 pass
00150             except:
00151                 pass
00152             try:
00153                 pass
00154             except:
00155                 pass
00156             try:
00157                 pass
00158             except:
00159                 pass
00160             try:
00161                 pass
00162             except:
00163                 pass
00164             try:
00165                 pass
00166             except:
00167                 pass
00168             try:
00169                 pass
00170             except:
00171                 pass
00172             try:
00173                 pass
00174             except:
00175                 pass
00176             try:
00177                 pass
00178             except:
00179                 pass
00180             try:
00181                 pass
00182             except:
00183                 pass
00184             try:
00185                 pass
00186             except:
00187                 pass
00188 
00189 
00190             try:
00191                 pass
00192             except:
00193                 pass
00194             try:
00195                 pass
00196             except:
00197                 pass
00198             try:
00199                 pass
00200             except:
00201                 pass
00202             try:
00203                 pass
00204             except:
00205                 pass
00206             try:
00207                 pass
00208             except:
00209                 pass
00210             try:
00211                 pass
00212             except:
00213                 pass
00214             try:
00215                 pass
00216             except:
00217                 pass
00218             try:
00219                 pass
00220             except:
00221                 pass
00222             try:
00223                 pass
00224             except:
00225                 pass
00226             try:
00227                 pass
00228             except:
00229                 pass
00230 
00231 
00232             try:
00233                 pass
00234             except:
00235                 pass
00236             try:
00237                 pass
00238             except:
00239                 pass
00240             try:
00241                 pass
00242             except:
00243                 pass
00244             try:
00245                 pass
00246             except:
00247                 pass
00248             try:
00249                 pass
00250             except:
00251                 pass
00252             try:
00253                 pass
00254             except:
00255                 pass
00256             try:
00257                 pass
00258             except:
00259                 pass
00260             try:
00261                 pass
00262             except:
00263                 pass
00264             try:
00265                 pass
00266             except:
00267                 pass
00268             try:
00269                 pass
00270             except:
00271                 pass
00272 
00273             try:
00274                 pass
00275             except:
00276                 pass
00277             try:
00278                 pass
00279             except:
00280                 pass
00281             try:
00282                 pass
00283             except:
00284                 pass
00285             try:
00286                 pass
00287             except:
00288                 pass
00289             try:
00290                 pass
00291             except:
00292                 pass
00293             try:
00294                 pass
00295             except:
00296                 pass
00297             try:
00298                 pass
00299             except:
00300                 pass
00301             try:
00302                 pass
00303             except:
00304                 pass
00305             try:
00306                 pass
00307             except:
00308                 pass
00309             try:
00310                 pass
00311             except:
00312                 pass
00313 
00314             try:
00315                 pass
00316             except:
00317                 pass
00318             try:
00319                 pass
00320             except:
00321                 pass
00322             try:
00323                 pass
00324             except:
00325                 pass
00326             try:
00327                 pass
00328             except:
00329                 pass
00330             try:
00331                 pass
00332             except:
00333                 pass
00334             try:
00335                 pass
00336             except:
00337                 pass
00338             try:
00339                 pass
00340             except:
00341                 pass
00342             try:
00343                 pass
00344             except:
00345                 pass
00346             try:
00347                 pass
00348             except:
00349                 pass
00350             try:
00351                 pass
00352             except:
00353                 pass
00354 
00355 
00356             try:
00357                 pass
00358             except:
00359                 pass
00360             try:
00361                 pass
00362             except:
00363                 pass
00364             try:
00365                 pass
00366             except:
00367                 pass
00368             try:
00369                 pass
00370             except:
00371                 pass
00372             try:
00373                 pass
00374             except:
00375                 pass
00376             try:
00377                 pass
00378             except:
00379                 pass
00380             try:
00381                 pass
00382             except:
00383                 pass
00384             try:
00385                 pass
00386             except:
00387                 pass
00388             try:
00389                 pass
00390             except:
00391                 pass
00392             try:
00393                 pass
00394             except:
00395                 pass
00396 
00397 
00398             try:
00399                 pass
00400             except:
00401                 pass
00402             try:
00403                 pass
00404             except:
00405                 pass
00406             try:
00407                 pass
00408             except:
00409                 pass
00410             try:
00411                 pass
00412             except:
00413                 pass
00414             try:
00415                 pass
00416             except:
00417                 pass
00418             try:
00419                 pass
00420             except:
00421                 pass
00422             try:
00423                 pass
00424             except:
00425                 pass
00426             try:
00427                 pass
00428             except:
00429                 pass
00430             try:
00431                 pass
00432             except:
00433                 pass
00434             try:
00435                 pass
00436             except:
00437                 pass
00438 
00439 
00440             try:
00441                 pass
00442             except:
00443                 pass
00444             try:
00445                 pass
00446             except:
00447                 pass
00448             try:
00449                 pass
00450             except:
00451                 pass
00452             try:
00453                 pass
00454             except:
00455                 pass
00456             try:
00457                 pass
00458             except:
00459                 pass
00460             try:
00461                 pass
00462             except:
00463                 pass
00464             try:
00465                 pass
00466             except:
00467                 pass
00468             try:
00469                 pass
00470             except:
00471                 pass
00472             try:
00473                 pass
00474             except:
00475                 pass
00476             try:
00477                 pass
00478             except:
00479                 pass
00480 
00481             try:
00482                 pass
00483             except:
00484                 pass
00485             try:
00486                 pass
00487             except:
00488                 pass
00489             try:
00490                 pass
00491             except:
00492                 pass
00493             try:
00494                 pass
00495             except:
00496                 pass
00497             try:
00498                 pass
00499             except:
00500                 pass
00501             try:
00502                 pass
00503             except:
00504                 pass
00505             try:
00506                 pass
00507             except:
00508                 pass
00509             try:
00510                 pass
00511             except:
00512                 pass
00513             try:
00514                 pass
00515             except:
00516                 pass
00517             try:
00518                 pass
00519             except:
00520                 pass
00521 
00522             try:
00523                 pass
00524             except:
00525                 pass
00526             try:
00527                 pass
00528             except:
00529                 pass
00530             try:
00531                 pass
00532             except:
00533                 pass
00534             try:
00535                 pass
00536             except:
00537                 pass
00538             try:
00539                 pass
00540             except:
00541                 pass
00542             try:
00543                 pass
00544             except:
00545                 pass
00546             try:
00547                 pass
00548             except:
00549                 pass
00550             try:
00551                 pass
00552             except:
00553                 pass
00554             try:
00555                 pass
00556             except:
00557                 pass
00558             try:
00559                 pass
00560             except:
00561                 pass
00562 
00563 
00564             try:
00565                 pass
00566             except:
00567                 pass
00568             try:
00569                 pass
00570             except:
00571                 pass
00572             try:
00573                 pass
00574             except:
00575                 pass
00576             try:
00577                 pass
00578             except:
00579                 pass
00580             try:
00581                 pass
00582             except:
00583                 pass
00584             try:
00585                 pass
00586             except:
00587                 pass
00588             try:
00589                 pass
00590             except:
00591                 pass
00592             try:
00593                 pass
00594             except:
00595                 pass
00596             try:
00597                 pass
00598             except:
00599                 pass
00600             try:
00601                 pass
00602             except:
00603                 pass
00604 
00605 
00606             try:
00607                 pass
00608             except:
00609                 pass
00610             try:
00611                 pass
00612             except:
00613                 pass
00614             try:
00615                 pass
00616             except:
00617                 pass
00618             try:
00619                 pass
00620             except:
00621                 pass
00622             try:
00623                 pass
00624             except:
00625                 pass
00626             try:
00627                 pass
00628             except:
00629                 pass
00630             try:
00631                 pass
00632             except:
00633                 pass
00634             try:
00635                 pass
00636             except:
00637                 pass
00638             try:
00639                 pass
00640             except:
00641                 pass
00642             try:
00643                 pass
00644             except:
00645                 pass
00646 
00647 
00648             try:
00649                 pass
00650             except:
00651                 pass
00652             try:
00653                 pass
00654             except:
00655                 pass
00656             try:
00657                 pass
00658             except:
00659                 pass
00660             try:
00661                 pass
00662             except:
00663                 pass
00664             try:
00665                 pass
00666             except:
00667                 pass
00668             try:
00669                 pass
00670             except:
00671                 pass
00672             try:
00673                 pass
00674             except:
00675                 pass
00676             try:
00677                 pass
00678             except:
00679                 pass
00680             try:
00681                 pass
00682             except:
00683                 pass
00684             try:
00685                 pass
00686             except:
00687                 pass

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 58 of file Exceptions.py.

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

Definition at line 209 of file pybench.py.

int Exceptions.TryExcept.rounds = 150000 [static]

Reimplemented from pybench.Test.

Definition at line 59 of file Exceptions.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 Exceptions.TryExcept.version = 2.0 [static]

Instance variables that each test should override.

Reimplemented from pybench.Test.

Definition at line 57 of file Exceptions.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: