tf_test.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # tf_test Unit test for Text File manipulations
  2. import tf
  3. # you should have a medium sized file called 'a' in '/'
  4. # and free space equivalent to 2x the size of 'a'
  5. def bench():
  6. import time
  7. a=time.ticks_us()
  8. cp('a','b')
  9. b=time.ticks_us()
  10. print("time to copy={}".format((b-a)/1e6))
  11. input("next")
  12. a=time.ticks_us()
  13. grep('a','kernel')
  14. b=time.ticks_us()
  15. print("time to grep={}".format((b-a)/1e6))
  16. input("next")
  17. a=time.ticks_us()
  18. sed('a','s/kernel\s*/KERNEL /')
  19. b=time.ticks_us()
  20. print("time to sed-replace={}".format((b-a)/1e6))
  21. input("next")
  22. os.remove('a.bak')
  23. a=time.ticks_us()
  24. cp('b','a')
  25. b=time.ticks_us()
  26. print("time to copy={}".format((b-a)/1e6))
  27. input("next")
  28. a=time.ticks_us()
  29. sed('a','100-130x/(PM|AGP):/')
  30. b=time.ticks_us()
  31. print("time to sed-extract{}".format((b-a)/1e6))
  32. input("next")
  33. a=time.ticks_us()
  34. cat('b', numbers=True)
  35. b=time.ticks_us()
  36. print("time to cat= {}".format((b-a)/1e6))
  37. input("next")
  38. os.remove('a.bak')
  39. cp('b','a')
  40. a=time.ticks_us()
  41. sed('a', '100a!! a line of text!!')
  42. b=time.ticks_us()
  43. print("time to sed-insert= {}".format((b-a)/1e6))
  44. os.remove('a.bak')