Skip to content
Snippets Groups Projects
Commit 2e74034c6140 authored by Boris Feld's avatar Boris Feld
Browse files

More cleaning and refactoring.

Extract the common variants in a separate class.
Also forces the benchmarks to run in a clean environment.
parent 6c47cf2d5a65
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
......@@ -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"]
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