Python C extension to compute the permanent.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

run-tests.py 882B

il y a 9 ans
1234567891011121314151617181920212223242526272829303132333435
  1. import os
  2. import time
  3. import multiprocessing as mp
  4. import numpy as np
  5. import lib
  6. def test_fn(perm_fn, name, dimension=6, steps=1000, dt=1e-3, bodies=101, threads=1):
  7. # Test the speed of the evolution function.
  8. sreal=np.random.uniform(0,1,(dimension, dimension))
  9. scomp=np.random.uniform(0,1,(dimension, dimension))
  10. submatrix=sreal+1j*scomp
  11. t0 = time.time()
  12. for i in range(steps):
  13. p=perm_fn(submatrix)
  14. t1 = time.time()
  15. print "{0} ({1}): {2} steps/sec".format(name, threads, int(steps / (t1 - t0)))
  16. if __name__ == "__main__":
  17. d=4
  18. steps=1000
  19. # Test on one core
  20. test_fn(lib.perm_python, "1 core, C", steps=steps, threads=1)
  21. # Test on one core
  22. test_fn(lib.perm_c, "1 core, C", steps=steps, threads=1)
  23. # Test on four cores
  24. test_fn(lib.perm_c, "All cores, C", steps=steps/threads, threads=threads)