|
Last change
on this file since 1538 was 2, checked in by Yuri Dario, 15 years ago |
|
Initial import for vendor code.
|
-
Property svn:eol-style
set to
native
|
|
File size:
575 bytes
|
| Line | |
|---|
| 1 | # Simple interface to report execution times of program fragments.
|
|---|
| 2 | # Call TSTART() to reset the timer, TSTOP(...) to report times.
|
|---|
| 3 |
|
|---|
| 4 | import sys, os, time
|
|---|
| 5 |
|
|---|
| 6 | def TSTART():
|
|---|
| 7 | global t0, t1
|
|---|
| 8 | u, s, cu, cs = os.times()
|
|---|
| 9 | t0 = u+cu, s+cs, time.time()
|
|---|
| 10 |
|
|---|
| 11 | def TSTOP(*label):
|
|---|
| 12 | global t0, t1
|
|---|
| 13 | u, s, cu, cs = os.times()
|
|---|
| 14 | t1 = u+cu, s+cs, time.time()
|
|---|
| 15 | tt = []
|
|---|
| 16 | for i in range(3):
|
|---|
| 17 | tt.append(t1[i] - t0[i])
|
|---|
| 18 | [u, s, r] = tt
|
|---|
| 19 | msg = ''
|
|---|
| 20 | for x in label: msg = msg + (x + ' ')
|
|---|
| 21 | msg = msg + '%r user, %r sys, %r real\n' % (u, s, r)
|
|---|
| 22 | sys.stderr.write(msg)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.