|
27 | 27 | from zodbshootout.fork import distribute
|
28 | 28 | from zodbshootout.fork import run_in_child
|
29 | 29 | from ZODB._compat import dumps
|
30 |
| -import optparse |
| 30 | +import argparse |
31 | 31 | import os
|
32 | 32 | import sys
|
33 | 33 | import time
|
@@ -275,40 +275,42 @@ def main(argv=None):
|
275 | 275 | if argv is None:
|
276 | 276 | argv = sys.argv[1:]
|
277 | 277 |
|
278 |
| - parser = optparse.OptionParser(usage='%prog [options] config_file') |
279 |
| - parser.add_option( |
280 |
| - "-n", "--object-counts", dest="counts", default="1000", |
281 |
| - help="Object counts to use, separated by commas (default 1000)", |
| 278 | + parser = argparse.ArgumentParser() |
| 279 | + parser.add_argument( |
| 280 | + "-n", "--object-counts", dest="counts", |
| 281 | + type=int, |
| 282 | + action="append", |
| 283 | + help="Object counts to use (default 1000). Use this option as many times as you want.", |
282 | 284 | )
|
283 |
| - parser.add_option( |
284 |
| - "-s", "--object-size", dest="object_size", default="115", |
| 285 | + parser.add_argument( |
| 286 | + "-s", "--object-size", dest="object_size", default=115, |
| 287 | + type=int, |
285 | 288 | help="Size of each object in bytes (estimated, default approx. 115)",
|
286 | 289 | )
|
287 |
| - parser.add_option( |
288 |
| - "-c", "--concurrency", dest="concurrency", default="2", |
289 |
| - help="Concurrency levels to use, separated by commas (default 2)", |
| 290 | + parser.add_argument( |
| 291 | + "-c", "--concurrency", dest="concurrency", |
| 292 | + type=int, |
| 293 | + action="append", |
| 294 | + help="Concurrency levels to use. Default is 2. Use this option as many times as you want." |
290 | 295 | )
|
291 |
| - parser.add_option( |
| 296 | + parser.add_argument( |
292 | 297 | "-p", "--profile", dest="profile_dir", default="",
|
293 | 298 | help="Profile all tests and output results to the specified directory",
|
294 | 299 | )
|
| 300 | + parser.add_argument("config_file", type=argparse.FileType()) |
295 | 301 |
|
296 |
| - options, args = parser.parse_args(argv) |
297 |
| - if len(args) != 1: |
298 |
| - parser.error("exactly one database configuration file is required") |
299 |
| - conf_fn = args[0] |
| 302 | + options = parser.parse_args(argv) |
| 303 | + conf_fn = options.config_file |
300 | 304 |
|
301 |
| - object_counts = [int(x.strip()) |
302 |
| - for x in options.counts.split(',')] |
303 |
| - object_size = max(int(options.object_size), pobject_base_size) |
304 |
| - concurrency_levels = [int(x.strip()) |
305 |
| - for x in options.concurrency.split(',')] |
| 305 | + object_counts = options.counts or [1000] |
| 306 | + object_size = max(options.object_size, pobject_base_size) |
| 307 | + concurrency_levels = options.concurrency or [2] |
306 | 308 | profile_dir = options.profile_dir
|
307 | 309 | if profile_dir and not os.path.exists(profile_dir):
|
308 | 310 | os.makedirs(profile_dir)
|
309 | 311 |
|
310 | 312 | schema = ZConfig.loadSchemaFile(StringIO(schema_xml))
|
311 |
| - config, _handler = ZConfig.loadConfig(schema, conf_fn) |
| 313 | + config, _handler = ZConfig.loadConfigFile(schema, conf_fn) |
312 | 314 | contenders = [(db.name, db) for db in config.databases]
|
313 | 315 |
|
314 | 316 | txn_descs = (
|
|
0 commit comments