Skip to content

Commit e7d0a3d

Browse files
committed
Improve doc
1 parent 0450158 commit e7d0a3d

2 files changed

Lines changed: 42 additions & 9 deletions

File tree

tools/runbenchmark.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
#!/usr/bin/env python
2+
"""
3+
A benchmark runner.
4+
5+
Files and functions that match pattern 'benchmark_*' is executed as a benchmark.
6+
7+
Use decorator `benchmark_setup` to run setup before run benchmark.
8+
9+
A typical benchmark example:
10+
```
11+
@benchmark_setup(hack_into=int)
12+
def benchmark_print_int(hack_into):
13+
for i in range(100):
14+
print(hack_info)
15+
```
16+
17+
18+
"""
219
import glob
320
import os
421
import argparse
@@ -153,15 +170,23 @@ def _pretty_rv(loop, repeat, costs):
153170

154171

155172
def main():
156-
parser = argparse.ArgumentParser()
173+
parser = argparse.ArgumentParser(
174+
prog=os.path.basename(sys.argv[0]), description=__doc__.lstrip().splitlines()[0]
175+
)
157176
parser.add_argument("path", default=["."], nargs="+")
158-
parser.add_argument("-p", "--python-path", default=["."], nargs="*")
177+
parser.add_argument(
178+
"-p",
179+
"--python-path",
180+
default=["."],
181+
nargs="*",
182+
help="paths inserted to sys.path",
183+
)
159184
parser.add_argument(
160185
"-e",
161186
"--error-exit",
162187
default=False,
163188
action="store_true",
164-
help="Exit if error occurred",
189+
help="exit if error occurred",
165190
)
166191

167192
args = parser.parse_args()

tools/runtest.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/usr/bin/env python
2+
"""
3+
A auto unit tests runner for CTools.
4+
5+
Use standard unittest library, so we can run in any python environment (no need install pytest).
6+
7+
"""
28
import sys
39
import os
410
import shutil
@@ -37,25 +43,27 @@ def _show_info():
3743
sys.stderr.flush()
3844

3945

40-
parser = argparse.ArgumentParser()
46+
parser = argparse.ArgumentParser(
47+
prog=os.path.basename(sys.argv[0]), description=__doc__.lstrip().splitlines()[0]
48+
)
4149
parser.add_argument(
42-
"-k", dest="pattern", help="Only run tests which match the given substring"
50+
"-k", dest="pattern", help="only run tests which match the given substring"
4351
)
44-
parser.add_argument("-v", "--verbose", dest="verbose", help="Verbose output")
45-
parser.add_argument("-q", "--quiet", dest="quiet", help="Quiet output")
52+
parser.add_argument("-v", "--verbose", dest="verbose", help="verbose output")
53+
parser.add_argument("-q", "--quiet", dest="quiet", help="quiet output")
4654
parser.add_argument(
4755
"-s",
4856
"--start-directory",
4957
default=".",
5058
dest="start_directory",
51-
help="Directory to start discovery ('.' default)",
59+
help="directory to start discovery ('.' default)",
5260
)
5361
parser.add_argument(
5462
"-p",
5563
"--python-path",
5664
dest="python_path",
5765
action="append",
58-
help="Include python path",
66+
help="python path inserted into sys.path",
5967
)
6068

6169

0 commit comments

Comments
 (0)