diff --git a/benchmarks/basic_commands.py b/benchmarks/basic_commands.py index 6c47cf2d5a65674a094ca633a8436cd672bd23f0_YmVuY2htYXJrcy9iYXNpY19jb21tYW5kcy5weQ==..2e74034c61404b25bb3591db6377b6c3a65861e0_YmVuY2htYXJrcy9iYXNpY19jb21tYW5kcy5weQ== 100644 --- a/benchmarks/basic_commands.py +++ b/benchmarks/basic_commands.py @@ -3,10 +3,11 @@ import time import timeit -from .utils import REPOS, BaseTrackTestSuite, BaseTimeTestSuite, median +from .utils import (BaseNChangesetsTestSuite, BaseTimeTestSuite, + BaseTrackTestSuite, median) class TestSuite(BaseTrackTestSuite): timeout = 120 @@ -7,10 +8,10 @@ class TestSuite(BaseTrackTestSuite): timeout = 120 - def track_commit(self, repo_name): + def track_commit(self, *args, **kwargs): timings = [] args = ["-A", "-m", "My commit message", "-u", "<test@octobus.net>"] @@ -88,5 +89,5 @@ return time -class LogTimeTestSuite(BaseTimeTestSuite): +class LogTimeTestSuite(BaseNChangesetsTestSuite): @@ -92,6 +93,4 @@ - params = [REPOS, [10, 100, 1000, 10000]] - param_names = ["repo", "changesets"] timeout = 300 def __init__(self): @@ -104,5 +103,5 @@ self._execute("log", "-r", "tip~%d::" % n) -class UpdateTimeTestSuite(BaseTimeTestSuite): +class UpdateTimeTestSuite(BaseNChangesetsTestSuite): @@ -108,6 +107,4 @@ - params = [REPOS, [10, 100, 1000, 10000]] - param_names = ["repo", "changesets"] timeout = 500 def __init__(self): @@ -121,5 +118,5 @@ self._execute("up", "-r", "tip") -class BundleTimeTestSuite(BaseTimeTestSuite): +class BundleTimeTestSuite(BaseNChangesetsTestSuite): @@ -125,6 +122,4 @@ - params = [REPOS, [10, 100, 1000, 10000]] - param_names = ["repo", "changesets"] timeout = 500 def __init__(self): diff --git a/benchmarks/utils.py b/benchmarks/utils.py index 6c47cf2d5a65674a094ca633a8436cd672bd23f0_YmVuY2htYXJrcy91dGlscy5weQ==..2e74034c61404b25bb3591db6377b6c3a65861e0_YmVuY2htYXJrcy91dGlscy5weQ== 100644 --- a/benchmarks/utils.py +++ b/benchmarks/utils.py @@ -148,8 +148,11 @@ self.hgpath = os.path.join(venv, "bin", "hg") self.repo_path = os.path.join(REPOS_DIR, self.repo_name) + # Use a clean environ to run command + self.environ = {} + class BaseTrackTestSuite(BaseTestSuite): def _execute(self, command, *args): cmd = self._prepare_cmd(command, *args) @@ -151,10 +154,8 @@ class BaseTrackTestSuite(BaseTestSuite): def _execute(self, command, *args): cmd = self._prepare_cmd(command, *args) - # Clean environ - os.environ = {} timings = [] @@ -182,7 +183,8 @@ def _single_execute(self, cmd): try: before = time.time() - subprocess.check_output(cmd, stderr=subprocess.STDOUT) + subprocess.check_output(cmd, stderr=subprocess.STDOUT, + env=self.environ) after = time.time() return after - before except subprocess.CalledProcessError as e: @@ -212,4 +214,11 @@ return cmd def _single_execute(self, cmd): - return subprocess.check_output(cmd, stderr=subprocess.STDOUT) + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, + env=self.environ) + + +class BaseNChangesetsTestSuite(BaseTimeTestSuite): + + params = [REPOS, [10, 100, 1000, 10000]] + param_names = ["repo", "changesets"]