average 419 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/python
  2. import getopt
  3. import time
  4. import string
  5. import sys
  6. import os
  7. count = 10
  8. opts, args = getopt.getopt(sys.argv[1:], "n:")
  9. for opt in opts:
  10. if opt[0] == "-n":
  11. count = int(opt[1])
  12. length = 0.0
  13. i = 0
  14. while i < count:
  15. begin = time.time()
  16. cmd = '"' + string.join(args, '" "') + '"';
  17. os.system(cmd)
  18. length += time.time() - begin
  19. i += 1
  20. print >> sys.stderr, length / count