root / pobysoPythonSage / src / ppsTestFunctions.sage @ 280
Historique | Voir | Annoter | Télécharger (733 octet)
| 1 | 160 | storres | """ |
|---|---|---|---|
| 2 | 160 | storres | @file ppsTestFunctions.sage |
| 3 | 160 | storres | |
| 4 | 160 | storres | Module for functions used in all sorts of tests. |
| 5 | 160 | storres | |
| 6 | 160 | storres | AUTHORS: |
| 7 | 160 | storres | - S.T. (2015-05-03): initial version |
| 8 | 160 | storres | |
| 9 | 160 | storres | TODO: |
| 10 | 160 | storres | - almost everything! |
| 11 | 160 | storres | |
| 12 | 160 | storres | """ |
| 13 | 160 | storres | print "ppsTestFunctions loading..." |
| 14 | 160 | storres | import inspect |
| 15 | 160 | storres | import resource |
| 16 | 160 | storres | import timeit |
| 17 | 160 | storres | |
| 18 | 160 | storres | |
| 19 | 160 | storres | def pps_memory_usage(): |
| 20 | 160 | storres | rusage_denom = RR("1024")
|
| 21 | 160 | storres | if sys.platform == 'darwin': |
| 22 | 160 | storres | # ... it seems that in OSX the output is different units ... |
| 23 | 160 | storres | rusage_denom = rusage_denom * rusage_denom |
| 24 | 160 | storres | mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / rusage_denom |
| 25 | 160 | storres | return mem |
| 26 | 160 | storres | # End memory_usage_resource() |
| 27 | 160 | storres | |
| 28 | 160 | storres | def pps_test_wrapper(func, *args, **kwargs): |
| 29 | 160 | storres | def wrapped(): |
| 30 | 160 | storres | return func(*args, **kwargs) |
| 31 | 160 | storres | return wrapped |
| 32 | 160 | storres | |
| 33 | 160 | storres | print "\t...ppsTestFunctions loaded" |