spacepaste

  1.  
  2. On OS X, running with my latest changes to mercurial (all merged I believe), against pypy repo, @9573c6ca1519
  3. The bench_sub.py:
  4. import sys, time, os
  5. from mercurial import dispatch
  6. l = []
  7. for i in range(int(sys.argv[1])):
  8. t0 = time.time()
  9. dispatch.dispatch(dispatch.request(sys.argv[2:]))
  10. l.append(time.time() - t0)
  11. print >>sys.stderr, l
  12. bench.py:
  13. import os, sys
  14. import json, time
  15. from subprocess import Popen, PIPE, STDOUT
  16. def sanitize(cmd):
  17. if isinstance(cmd, File):
  18. return "file%d" % cmd.no
  19. return cmd
  20. class Command(object):
  21. def __init__(self, cmd, no, cleanup=None):
  22. self.cmd = cmd
  23. self.no = no
  24. self.cleanup = cleanup
  25. def repr(self):
  26. return " ".join([sanitize(x) for x in self.cmd])
  27. pypy_files = [
  28. 'rpython/jit/metainterp/pyjitpl.py',
  29. ]
  30. mercurial_files = [
  31. 'mercurial/manifest.py',
  32. ]
  33. class File(object):
  34. def __init__(self, no):
  35. self.no = no
  36. commands = [
  37. Command(['log'], 6),
  38. Command(['log', '-p', File(0)], 6),
  39. Command(['bundle', '-t', 'none', '-a', "'*'"], 1),
  40. Command(['bundle', '-t', 'gzip', '-a', "'*'"], 1),
  41. # unbundle, tested separately
  42. Command(['blame', File(0)], 20),
  43. Command(['diff'], 1000),
  44. # Command(['hg', 'up', 'null'], 10, ['hg', 'up', 'tip']) <- disabled, not CPU bound
  45. # http server, tested separately
  46. Command(['status'], 1000), # mostly listdir
  47. # rebase
  48. # amend
  49. # commit
  50. ]
  51. print "Using following benchmarks:"
  52. bench_sub = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'bench_sub.py')
  53. def run_benchmark(cmd, files):
  54. cmd_run = []
  55. for item in cmd.cmd:
  56. if isinstance(item, File):
  57. cmd_run.append(files[item.no])
  58. else:
  59. cmd_run.append(item)
  60. print "Running: " + " ".join(cmd_run)
  61. args = ['python', bench_sub, str(cmd.no)] + cmd_run
  62. p = Popen(args, stdout=PIPE, stderr=PIPE)
  63. stdout, stderr = p.communicate()
  64. if p.returncode != 0:
  65. print >>sys.stderr, "Output:\n" + stdout
  66. print >>sys.stderr, "Error:\n" + stderr
  67. raise Exception("returned " + str(p.returncode))
  68. else:
  69. d = {}
  70. exec("l = " + stderr) in d
  71. return d['l']
  72. if __name__ == '__main__':
  73. result = []
  74. for cmd in commands:
  75. result.append((cmd, run_benchmark(cmd, pypy_files)))
  76. open("result%d.json" % int(time.time()), "w").write(json.dumps({'version': 0.2, 'result':
  77. [(cmd.repr(), res) for cmd, res in result],
  78. 'executable': sys.executable}))
  79. print "Results:"
  80. print "Total: Warmed up:"
  81. for cmd, res in result:
  82. one_third = len(res) // 3
  83. r2 = res[one_third:]
  84. print "%.2fs %.2fs - %s" % (sum(res)/len(res), sum(r2)/len(r2), cmd.repr())
  85. """
  86. * hg log
  87. * hg log -p
  88. * hg bundle -t gzip -a - the main component of server side clone
  89. * hg unbundle - the main component of client side clone
  90. * hg blame
  91. * updating - hg up null followed by hg up tip
  92. * performance of http server (hg serve)
  93. * hg commit
  94. * hg amend
  95. * hg rebase
  96. * hg status
  97. """
  98. CPython:
  99. Total: Warmed up:
  100. 13.31s 13.28s - log
  101. 8.17s 8.16s - log -p file0
  102. 46.34s 46.34s - bundle -t none -a '*'
  103. 102.15s 102.15s - bundle -t gzip -a '*'
  104. 2.45s 2.42s - blame file0
  105. 0.03s 0.03s - diff
  106. 0.04s 0.04s - status
  107. PyPy before my commits:
  108. Total: Warmed up:
  109. 3.37s 3.17s - log
  110. 23.59s 23.28s - log -p file0
  111. 52.40s 52.40s - bundle -t none -a '*'
  112. 113.61s 113.61s - bundle -t gzip -a '*'
  113. 5.56s 5.48s - blame file0
  114. 0.11s 0.11s - diff
  115. 0.14s 0.14s - status
  116. PyPy now:
  117. Total: Warmed up:
  118. 3.76s 3.43s - log
  119. 10.18s 9.96s - log -p file0
  120. 58.33s 58.33s - bundle -t none -a '*'
  121. 93.77s 93.77s - bundle -t gzip -a '*'
  122. 2.33s 2.27s - blame file0
  123. 0.04s 0.04s - diff
  124. 0.05s 0.05s - status
  125.