Skip to content

Commit

Permalink
Added an argument to select a benchmark dir.
Browse files Browse the repository at this point in the history
This means you could now use the harness to benchmark other things, so I
suppose this is now a general purpose Django benchmarking library. Thanks
to Eric Holscher for the idea.
  • Loading branch information
jacobian committed Jun 23, 2010
1 parent ed837b6 commit 432e496
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions djangobench/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from unipath import DIRS, FSPath as Path
from djangobench import perf

BENCMARK_DIR = Path(__file__).parent.child('benchmarks').absolute()
DEFAULT_BENCMARK_DIR = Path(__file__).parent.child('benchmarks').absolute()

def run_benchmarks(control, experiment, benchmarks, trials, dump_times=False, benchmark_dir=BENCMARK_DIR):
def run_benchmarks(control, experiment, benchmark_dir, benchmarks, trials, dump_times):
if benchmarks:
print "Running benchmarks: %s" % " ".join(benchmarks)
else:
Expand Down Expand Up @@ -190,15 +190,30 @@ def main():
default = False,
help = 'Dump raw times to stdout. Careful - prints a *lot* of data!',
)
parser.add_argument(
'--benchmark-dir',
dest = 'benchmark_dir',
default = DEFAULT_BENCMARK_DIR,
help = ('Directory to inspect for benchmarks. Defaults to the '
'benchmarks included with djangobench.'),
)
parser.add_argument(
'benchmarks',
metavar = 'name',
default = None,
help = "Benchmarks to be run. Defaults to all.",
nargs = '*'
)

args = parser.parse_args()
run_benchmarks(args.control, args.experiment, args.benchmarks, args.trials, args.dump_times)
run_benchmarks(
control = args.control,
experiment = args.experiment,
benchmark_dir = args.benchmark_dir,
benchmarks = args.benchmarks,
trials = args.trials,
dump_times = args.dump_times
)

if __name__ == '__main__':
main()

0 comments on commit 432e496

Please sign in to comment.