Advertisement
UnitBus

filecmp vs getmtime

Feb 15th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. # ファイルの比較(size-108MB)
  2. import time
  3. filePathA = r"F:\username\maya\projects\maya2016\scenes\XX\textures\test.1002.tga"
  4. filePathB = r"P:\XX\username\Textures\test.1002.tga"
  5.  
  6. timer = time.time()
  7. import filecmp
  8. if filecmp.cmp(filePathA, filePathB):
  9.     print time.time() - timer
  10.        
  11. timer = time.time()
  12. import datetime
  13. fileDateA = datetime.datetime.fromtimestamp(os.path.getmtime(filePathA)).strftime('%Y%m%d%H%M%S')
  14. fileDateB = datetime.datetime.fromtimestamp(os.path.getmtime(filePathB)).strftime('%Y%m%d%H%M%S')
  15. if fileDateA == fileDateB:
  16.     print time.time() - timer
  17.  
  18. # # 1回目
  19. # 1.7460000515
  20. # 0.00499987602234
  21.  
  22. # # 2回目
  23. # 0.00500011444092
  24. # 0.00200009346008
  25.  
  26. # # 3回目
  27. # 0.0019998550415
  28. # 0.0019998550415
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement