Skip to content
Snippets Groups Projects
Commit f55e7b52 authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

Introduce a _timeit() that allow tracking wrapped methods

When our benchmark is a single hg execute but with pre/post setup it's
convenient to wrap call to _single_execute().
parent 68f65450
No related branches found
No related tags found
No related merge requests found
......@@ -154,5 +154,15 @@
class BaseTrackTestSuite(BaseTestSuite):
def _timeit(self, func, args=(), kwargs=None):
kwargs = kwargs or {}
# Do a first measurement
first_measure = func(*args, **kwargs)
n = int(30 / first_measure)
times = []
for i in range(n):
times.append(func(*args, **kwargs))
return median(times)
def _execute(self, command, *args):
cmd = self._prepare_cmd(command, *args)
......@@ -157,17 +167,6 @@
def _execute(self, command, *args):
cmd = self._prepare_cmd(command, *args)
timings = []
# Do a first measurement
first_measure = self._single_execute(cmd)
N = int(30 / first_measure)
for i in range(N):
timings.append(self._single_execute(cmd))
return median(timings)
return self._timeit(self._single_execute, (cmd,))
def _prepare_cmd(self, command, *args):
cmd = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment