Skip to content

Commit

Permalink
Runner now runs local tests against a separate install.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 25, 2021
1 parent 6cb8109 commit cc46258
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.5.0
======

Runner now creates a separate environment for the local package,
avoiding relying on the environment under test, thus providing a
better comparison.

v0.4.0
======

Expand Down
14 changes: 7 additions & 7 deletions pytest_perf/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Command(list):
def __init__(self, exercise='pass', warmup='pass'):
self[:] = [
sys.executable,
'-s',
'-m',
'timeit',
'--setup',
Expand Down Expand Up @@ -70,18 +71,17 @@ class BenchmarkRunner:
"""

def __init__(self, extras=None):
self.extras_spec = f'[{extras}]' if extras else ''
self.baseline_env = self._setup_env()
spec = f'[{extras}]' if extras else ''
self.baseline_env = self._setup_env(upstream_url(spec))
self.local_env = self._setup_env(f'.{spec}')

def _setup_env(self):
def _setup_env(self, deps):
self.stack = contextlib.ExitStack()
target = self.stack.enter_context(
pip_run.deps.load(upstream_url(self.extras_spec))
)
target = self.stack.enter_context(pip_run.deps.load(deps))
return pip_run.launch._setup_env(target)

def run(self, cmd: Command):
local = self.eval(cmd)
local = self.eval(cmd, env=self.local_env)
benchmark = self.eval(cmd, env=self.baseline_env)
return Result(benchmark, local)

Expand Down

0 comments on commit cc46258

Please sign in to comment.