Guest User

пример 1

a guest
Jul 22nd, 2013
505
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import psutil
  2. from time import time
  3.  
  4. def timed(fn):
  5.     def decorated(*x):
  6.         start = time()
  7.         result = fn(*x)
  8.         print "Executing %s took %d ms" % (fn.__name__, (time()-start)*1000)
  9.         return result
  10.     return decorated
  11.  
  12. @timed
  13. def cpuload():
  14.     load = psutil.cpu_percent()
  15.     print "cpuload() returns %d" % load
  16.     return load
  17.  
  18. print "cpuload.__name__==" + cpuload.__name__
  19. print "CPU load is %d%%" % cpuload()
RAW Paste Data