diff --git a/pyperformance/_benchmark.py b/pyperformance/_benchmark.py index cd51dfe6..516fbbd1 100644 --- a/pyperformance/_benchmark.py +++ b/pyperformance/_benchmark.py @@ -252,7 +252,7 @@ def _resolve_restricted_opts(opts): if opt.startswith(FLAG + '='): idx = i + 1 resolved.append(FLAG) - resolved.append(opt.partition('=')[-2]) + resolved.append(opt.partition('=')[-1]) resolved.extend(opts[idx:]) break elif opt == FLAG: diff --git a/pyperformance/cli.py b/pyperformance/cli.py index 95f78429..ae30a682 100644 --- a/pyperformance/cli.py +++ b/pyperformance/cli.py @@ -60,6 +60,8 @@ def parse_args(): cmd.add_argument("--append", metavar="FILENAME", help="Add runs to an existing file, or create it " "if it doesn't exist") + cmd.add_argument("--track-energy", action="store_true", + help="Track energy instead of wall clock time.") filter_opts(cmd) # show diff --git a/pyperformance/data-files/requirements.txt b/pyperformance/data-files/requirements.txt index f59bc323..c94d8fe5 100644 --- a/pyperformance/data-files/requirements.txt +++ b/pyperformance/data-files/requirements.txt @@ -10,7 +10,7 @@ psutil==5.8.0 # via -r requirements.in pyparsing==3.0.6 # via packaging -pyperf==2.3.0 +pyperf @ file:///home/cappadokes/code/pyperf # via -r requirements.in toml==0.10.2 # via -r requirements.in diff --git a/pyperformance/run.py b/pyperformance/run.py index 8e196547..871ade01 100644 --- a/pyperformance/run.py +++ b/pyperformance/run.py @@ -190,7 +190,26 @@ def get_pyperf_opts(options): opts.append('--affinity=%s' % options.affinity) if options.track_memory: opts.append('--track-memory') - if options.inherit_environ: + if options.inherit_environ or options.track_energy: + # In the track_energy case, pyperf will need + # a couple of env variables to work. We save + # the user from manual insertion of --inherit-environ. + if options.track_energy: + if options.inherit_environ is None: + options.inherit_environ = [] + from os import environ as curr_env + env = curr_env + try: + lib = env['READEN'] + f = env['ENFILE'] + ld = env['LD_LIBRARY_PATH'] + options.inherit_environ.append('READEN') + options.inherit_environ.append('ENFILE') + options.inherit_environ.append('LD_LIBRARY_PATH') + except: + raise OSError('--track-energy needs READEN, ENFILE environment variables to work.') opts.append('--inherit-environ=%s' % ','.join(options.inherit_environ)) - + if options.track_energy: + opts.append('--track-energy') + return opts