Skip to content

Commit f5c807d

Browse files
authored
Merge pull request #52 from nicholasjng/env-refactor
Refactor most of the project to new concepts
2 parents 4fda33c + bf7a7a2 commit f5c807d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2465
-2067
lines changed

.github/workflows/ci.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Check out pybm
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717

1818
- name: Set up Python 3.9
19-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@v3
2020
with:
2121
python-version: 3.9
2222

@@ -30,24 +30,24 @@ jobs:
3030
example: [sum-example, sum-example-gbm]
3131
steps:
3232
- name: Check out pybm
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v3
3434

3535
- name: Check out ${{ matrix.example }} repo
36-
uses: actions/checkout@v2
36+
uses: actions/checkout@v3
3737
with:
3838
fetch-depth: 0
3939
repository: nicholasjng/pybm-${{ matrix.example }}
4040
path: ${{ matrix.example }}
4141

4242
- name: Set up Python 3.9
43-
uses: actions/setup-python@v2
43+
uses: actions/setup-python@v3
4444
with:
4545
python-version: 3.9
4646

4747
- name: Install pybm and other Python dependencies
4848
run: |
4949
python -m pip install wheel
50-
python -m pip install .. git+https://github.com/google/benchmark
50+
python -m pip install .. google-benchmark
5151
working-directory: ${{ matrix.example }}
5252

5353
- name: Create virtual environment with the current pybm checkout

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
repos:
22
- repo: https://gitlab.com/pycqa/flake8
3-
rev: '4.0.1'
3+
rev: 4.0.1
44
hooks:
55
- id: flake8
66

77
- repo: https://github.com/pre-commit/mirrors-mypy
8-
rev: 'v0.931'
8+
rev: v0.942
99
hooks:
1010
- id: mypy
1111
files: pybm/
1212

1313
- repo: https://github.com/psf/black
14-
rev: 22.1.0
14+
rev: 22.3.0
1515
hooks:
1616
- id: black
1717
language_version: python3

docs/commands/env.md

-171
This file was deleted.

docs/commands/run.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
```shell
44
➜ pybm run -h
5-
usage: pybm run <benchmark> <environment(s)> [<options>]
5+
usage: pybm run <benchmark> <workspace(s)> [<options>]
66

7-
Run pybm benchmark workloads in specified environments.
7+
Run pybm benchmark workloads in specified workspaces.
88

99
positional arguments:
1010
<benchmark> Name of the benchmark target(s) to run. Can be a path to a single file, a directory, or a glob expression. Given paths need to be relative to the worktree root.
11-
<environment(s)> Environments to run the benchmarks in. If omitted, by default, benchmarks will be run in the main environment if only one environment exists, otherwise an error will be raised,
11+
<workspace(s)> Environments to run the benchmarks in. If omitted, by default, benchmarks will be run in the main workspace if only one workspace exists, otherwise an error will be raised,
1212
unless the "--all" switch is used.
1313

1414
optional arguments:
1515
-h, --help Show this message and exit.
1616
-v Enable verbose mode. Makes pybm log information that might be useful for debugging.
1717
-m Run benchmark targets as modules. Use this to benchmark code outside of a package.
18-
--checkout Run benchmarks in checkout mode in environment "root". Here, instead of persisted git worktrees, different refs are benchmarked using `git checkout` commands.
19-
--all Run specified benchmarks in all existing pybm environments.
18+
--checkout Run benchmarks in checkout mode in workspace "root". Here, instead of persisted git worktrees, different refs are benchmarked using `git checkout` commands.
19+
--all Run specified benchmarks in all existing pybm workspaces.
2020
-S <git-ref>, --source <git-ref>
2121
Source benchmark targets from a different git reference.
2222
--repetitions <reps> Number of repetitions for the target benchmarks.
@@ -25,39 +25,39 @@ optional arguments:
2525
```
2626
2727
The `pybm run` command is perhaps the heart of `pybm`'s functionality. It is responsible for discovering, dispatching
28-
and running the appropriate benchmarks across the chosen environments. There are multiple nuances to running benchmarks
28+
and running the appropriate benchmarks across the chosen workspaces. There are multiple nuances to running benchmarks
2929
in pybm, all of which will be covered now.
3030
3131
## Understanding the basics
3232
3333
If you have your benchmarks under a `benchmarks` folder in your project, run all benchmarks like this, supposing you
34-
want to run them sequentially in environments named `my-env1` to `my-envN`:
34+
want to run them sequentially in workspaces named `my-workspace1` to `my-workspaceN`:
3535
3636
```shell
37-
pybm run benchmarks my-env1 my-env2 ... my-envN
37+
pybm run benchmarks my-workspace1 my-workspace2 ... my-workspaceN
3838
```
3939
40-
This will run the benchmarks in all the environments from my-env1 to my-envN.
40+
This will run the benchmarks in all the workspaces from my-workspace1 to my-workspaceN.
4141
4242
Running a single file (let it be `foo.py`) inside a folder also works:
4343
4444
```shell
45-
pybm run benchmarks/foo.py my-env1 my-env2 ... my-envN
45+
pybm run benchmarks/foo.py my-workspace1 my-workspace2 ... my-workspaceN
4646
```
4747
4848
Lastly, you can also supply a glob expression:
4949
5050
```shell
5151
# runs all benchmark files starting with foo.
52-
pybm run benchmarks/foo*.py my-env1 my-env2 ... my-envN
52+
pybm run benchmarks/foo*.py my-workspace1 my-workspace2 ... my-workspaceN
5353
```
5454
55-
## Running benchmarks in all available environments
55+
## Running benchmarks in all available workspaces
5656
57-
To run a benchmark in *all* available environments (list them with `pybm env list`), use the `--all` switch:
57+
To run a benchmark in *all* available workspaces (list them with `pybm workspace list`), use the `--all` switch:
5858
5959
```shell
60-
# runs all files in the benchmarks folder in all environments.
60+
# runs all files in the benchmarks folder in all workspaces.
6161
pybm run benchmarks --all
6262
```
6363
@@ -79,20 +79,20 @@ Instead of the slashes in the file path, you substitute those with dots to refle
7979
pybm supports running benchmark target files as modules like this:
8080
8181
```shell
82-
# runs the foo benchmark file as a module in the environment named my-env.
83-
pybm -m benchmarks/foo.py my-env
82+
# runs the foo benchmark file as a module in the workspace named my-workspace.
83+
pybm -m benchmarks/foo.py my-workspace
8484
```
8585
8686
Under the hood, this results in a `python -m benchmarks.foo` call, where the Python executable is sourced from the
87-
benchmark environment's associated virtual environment.
87+
benchmark workspace's associated virtual environment.
8888
8989
## Running benchmarks in checkout mode
9090
91-
For some use cases, creating different benchmark environments is overkill because there is no need for custom package
91+
For some use cases, creating different benchmark workspaces is overkill because there is no need for custom package
9292
dependencies, different Python versions etc. In this case, different versions of your Python codebase can be benchmarked
9393
with simple `git checkout` commands.
9494
95-
If you do not have any need for custom environments, then you can use the `--checkout` flag to run benchmarks in
95+
If you do not have any need for custom workspaces, then you can use the `--checkout` flag to run benchmarks in
9696
checkout mode:
9797
9898
```shell
@@ -109,7 +109,7 @@ Usually, as a rule of thumb, checkout mode can be used if:
109109
* Your project does not have any C extensions / libraries that need to be (re)compiled,
110110
* You want to use the same Python version for each of the benchmark runs.
111111
112-
If you do happen to meet any of the above criteria, consider using dedicated benchmark environments.
112+
If you do happen to meet any of the above criteria, consider using dedicated benchmark workspaces.
113113
114114
## Sourcing benchmarks from different references in checkout mode
115115

0 commit comments

Comments
 (0)