perf-tool: Port to argparse
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>
This commit is contained in:
parent
f4934c0421
commit
4c6bc1ed00
@ -7,7 +7,7 @@ try:
|
|||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
import optparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -279,37 +279,37 @@ def run_performance_test():
|
|||||||
|
|
||||||
# Main program
|
# Main program
|
||||||
|
|
||||||
parser = optparse.OptionParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_option("", "--perf", metavar="PERF_MODULE",
|
parser.add_argument("--perf",
|
||||||
help="Specify the name of a performance module to run")
|
help="Specify the name of a performance module to run")
|
||||||
parser.add_option("", "--perf-iters", type="int", metavar="ITERS",
|
parser.add_argument("--perf-iters", type=int, metavar="ITERS",
|
||||||
help="Numbers of iterations of performance module to run",
|
help="Numbers of iterations of performance module to run",
|
||||||
default=1)
|
default=1)
|
||||||
parser.add_option("", "--perf-warmup", action="store_true",
|
parser.add_argument("--perf-warmup", action="store_true",
|
||||||
help="Run a dry run before performance tests")
|
help="Run a dry run before performance tests")
|
||||||
parser.add_option("", "--perf-output", metavar="OUTPUT_FILE",
|
parser.add_argument("--perf-output", metavar="OUTPUT_FILE",
|
||||||
help="Output file to write performance report")
|
help="Output file to write performance report")
|
||||||
parser.add_option("", "--perf-upload", action="store_true",
|
parser.add_argument("--perf-upload", action="store_true",
|
||||||
help="Upload performance report to server")
|
help="Upload performance report to server")
|
||||||
parser.add_option("", "--extra-filter", action="append",
|
parser.add_argument("--extra-filter", action="append",
|
||||||
help="add an extra window class that should be allowed")
|
help="add an extra window class that should be allowed")
|
||||||
parser.add_option("", "--hwtest", action="store_true",
|
parser.add_argument("--hwtest", action="store_true",
|
||||||
help="Log results appropriately for GNOME Hardware Testing")
|
help="Log results appropriately for GNOME Hardware Testing")
|
||||||
parser.add_option("", "--version", action="callback", callback=show_version,
|
parser.add_argument("--version", action="version",
|
||||||
help="Display version and exit")
|
version="GNOME Shell Performance Test @VERSION@")
|
||||||
|
|
||||||
parser.add_option("-r", "--replace", action="store_true",
|
parser.add_argument("-r", "--replace", action="store_true",
|
||||||
help="Replace the running window manager")
|
help="Replace the running window manager")
|
||||||
parser.add_option("-w", "--wayland", action="store_true",
|
parser.add_argument("-w", "--wayland", action="store_true",
|
||||||
help="Run as a Wayland compositor")
|
help="Run as a Wayland compositor")
|
||||||
parser.add_option("-n", "--nested", action="store_true",
|
parser.add_argument("-n", "--nested", action="store_true",
|
||||||
help="Run as a Wayland nested compositor")
|
help="Run as a Wayland nested compositor")
|
||||||
parser.add_option("-x", "--x11", action="store_true",
|
parser.add_argument("-x", "--x11", action="store_true",
|
||||||
help="Run as an X11 compositor")
|
help="Run as an X11 compositor")
|
||||||
parser.add_option("", "--headless", action="store_true",
|
parser.add_argument("--headless", action="store_true",
|
||||||
help="Run as a headless Wayland compositor")
|
help="Run as a headless Wayland compositor")
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if options.perf == None:
|
if options.perf == None:
|
||||||
if options.hwtest:
|
if options.hwtest:
|
||||||
@ -323,10 +323,6 @@ if options.extra_filter is None:
|
|||||||
if options.perf == 'hwtest':
|
if options.perf == 'hwtest':
|
||||||
options.extra_filter.append('Gedit')
|
options.extra_filter.append('Gedit')
|
||||||
|
|
||||||
if args:
|
|
||||||
parser.print_usage()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
normal_exit = run_performance_test()
|
normal_exit = run_performance_test()
|
||||||
if normal_exit:
|
if normal_exit:
|
||||||
if not options.hwtest and options.replace:
|
if not options.hwtest and options.replace:
|
||||||
|
Loading…
Reference in New Issue
Block a user