Advertisement
Ayush1325

Untitled

Aug 20th, 2023 (edited)
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. import subprocess
  2. import os
  3. from timeit import Timer
  4.  
  5. args = ("cat", "/sys/bus/iio/devices/iio:device1/in_temp_raw")
  6.  
  7. def timing():
  8.     res = subprocess.run(args, capture_output=True)
  9.     if res.returncode:
  10.         os.exit(-1)
  11.  
  12. if __name__ == "__main__":
  13.     # Warmup
  14.     for i in range(5):
  15.         timing()
  16.  
  17.     print("Warmup done")
  18.  
  19.     while True:
  20.         t = Timer(timing).timeit(100) / 100
  21.         print(f"Time {t}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement