File: Timing.py

package info (click to toggle)
cython 0.15.1-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 16,480 kB
  • sloc: python: 45,354; xml: 1,031; cpp: 635; makefile: 229; lisp: 48; ansic: 28
file content (22 lines) | stat: -rw-r--r-- 403 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#
#   Get time in platform-dependent way
#

import os
from sys import platform, exit, stderr

if platform == 'mac':
  import MacOS
  def time():
    return MacOS.GetTicks() / 60.0
  timekind = "real"
elif hasattr(os, 'times'):
  def time():
    t = os.times()
    return t[0] + t[1]
  timekind = "cpu"
else:
  stderr.write(
    "Don't know how to get time on platform %s\n" % repr(platform))
  exit(1)