SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import psutil
  2. import os
  3. import random
  4. import gc
  5.  
  6. STRINGS = 10000
  7. LENGTH = 300
  8.  
  9. l = [None] * STRINGS
  10.  
  11. gc.collect()
  12.  
  13. init = (psutil.Process(os.getpid()).memory_info().vms)
  14.  
  15. for i in range(STRINGS):
  16.     l[i] = "".join(chr(random.randrange(1,2000)) for j in range(LENGTH))
  17.  
  18. gc.collect()
  19.  
  20. now = psutil.Process(os.getpid()).memory_info().vms
  21.  
  22. print(now, now-init, (now-init)/STRINGS)
  23.  
  24. init = now
  25.  
  26. for i in range(STRINGS):
  27.     l[i].encode()
  28.  
  29. gc.collect()
  30.  
  31. now = psutil.Process(os.getpid()).memory_info().vms
  32.  
  33. print(now, now-init, (now-init)/STRINGS)
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