Advertisement
Guest User

Untitled

a guest
May 6th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import os
  2. import time
  3. from borg.chunker import Chunker
  4.  
  5. CHUNK_MIN_EXP = 19 # 2**19 == 512kiB
  6. CHUNK_MAX_EXP = 23 # 2**23 == 8MiB
  7. HASH_WINDOW_SIZE = 0xfff # 4095B
  8. HASH_MASK_BITS = 21 # results in ~2MiB chunks statistically
  9.  
  10. CHUNKER_PARAMS = (CHUNK_MIN_EXP, CHUNK_MAX_EXP, HASH_MASK_BITS, HASH_WINDOW_SIZE)
  11.  
  12. seed = 1849058162
  13.  
  14. chunker = Chunker(seed, *CHUNKER_PARAMS)
  15.  
  16. flags_normal = os.O_RDONLY | getattr(os, 'O_BINARY', 0)
  17. flags_noatime = flags_normal | getattr(os, 'O_NOATIME', 0)
  18. fh = os.open("/Users/mikecampbell/Desktop/VMs/IE10 - Win7.ova", flags_noatime)
  19.  
  20. fd = os.fdopen(fh, 'rb')
  21.  
  22. chunks_count = 0
  23. t0 = time.time()
  24. for data in chunker.chunkify(fd, fh):
  25. chunks_count += 1
  26.  
  27. t1 = time.time()
  28. print(chunks_count)
  29. print(t1 - t0)
  30.  
  31. # 3799411200 bits in 15.18s
  32. # 250290593 b/s
  33. # 238 MB/s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement