Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 21st, 2011  |  syntax: Python  |  size: 0.41 KB  |  views: 56  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import numpy as np
  2. import timeit
  3.  
  4. N=4096
  5.  
  6. t_big=timeit.Timer('A.byteswap(True);A.tofile("a_big.bin")','import numpy;N={N};A=numpy.random.rand({N},{N})'.format(N=N))
  7. t_little=timeit.Timer('A.tofile("a_little.bin")','import numpy;N={N};A=numpy.random.rand({N},{N})'.format(N=N))
  8.  
  9. print("Running for little endian...")
  10. print t_little.repeat(5,10)
  11.  
  12. print("Running for big endian...")
  13. print t_big.repeat(5,10)