SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class CPU:
  2.     def __init__(self):
  3.         self.cpu_start()
  4.         self.list = []
  5.         self.a = 0
  6.         self.b = 0
  7.         self.c = 0
  8.     def cpu_start(self):
  9.         self.a = psutil.cpu_percent(interval=1, percpu=False)
  10.         return self.a
  11.     def cpu_end(self):
  12.         self.b = psutil.cpu_percent(interval=1, percpu=False)
  13.         return self.b
  14.     def diff(self):
  15.         self.c = self.cpu_start() - self.cpu_start()
  16.         return self.c
  17.  
  18. def main():
  19.     cpu = CPU()
  20.     results = []
  21.     while True:
  22.         results.append(cpu.diff())
  23.         print results
  24.  
  25. if __name__ == '__main__':
  26.     main()
  27.  
  28.  
  29. Below is the keyword:
  30.  
  31. Collect cpu before starting test case
  32.  
  33.   ${start}=  cpu_start
  34.   log  ${start}
  35.  
  36. Collect cpu after test case
  37.  
  38.   ${start2}=  cpu_end
  39.   log  ${start2}
  40.   ${start3}=  diff
  41.   log  ${start3}
  42.   ${start4}=  main
  43.   log  ${start4}
  44.  
  45. How to pass Main as variable in robot framework?
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top