chrono.py 625 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2009-2012 Lorenzo Caminiti
  2. # Distributed under the Boost Software License, Version 1.0
  3. # (see accompanying file LICENSE_1_0.txt or a copy at
  4. # http://www.boost.org/LICENSE_1_0.txt)
  5. # Home at http://www.boost.org/libs/local_function
  6. import sys
  7. import time
  8. import os
  9. if len(sys.argv) < 2:
  10. print "Usage: python " + sys.argv[0] + " COMMAND [COMMAND_OPTIONS]"
  11. print "Measure run-time of executing the specified command."
  12. exit(1)
  13. cmd = ""
  14. for arg in sys.argv[1:]: cmd += str(arg) + " "
  15. start = time.time()
  16. ret = os.system(cmd)
  17. sec = time.time() - start
  18. if (ret == 0): print "\n" + str(sec) + "s"