Skip to content

Commit

Permalink
EdkRepo: Adding performance option
Browse files Browse the repository at this point in the history
This new option will display the execution time of a successful command.

Cc: Ashley E Desimone <[email protected]>
Cc: Nate DeSimone <[email protected]>
Cc: Puja Pandya <[email protected]>
Cc: Bret Barkelew <[email protected]>
Cc: Prince Agyeman <[email protected]>
Cc: Erik Bjorge <[email protected]>
Signed-off-by: Erik Bjorge <[email protected]>
Reviewed-by: Ashley DeSimone <[email protected]>
Reviewed-by: Nate DeSimone <[email protected]>
  • Loading branch information
ErikBjorge authored and nate-desimone committed Oct 9, 2020
1 parent 04b701e commit 51eed87
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion edkrepo/commands/arguments/edkrepo_cmd_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## @file
# argument_strings.py
#
# Copyright (c) 2017- 2019, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#

Expand All @@ -17,3 +17,4 @@
SUBMODULE_SKIP_HELP = 'Skip the pull or sync of any submodules.'
COLOR_HELP = 'Force color output (useful with \'less -r\')'
SOURCE_MANIFEST_REPO_HELP = "The name of the workspace's source global manifest repository"
PERFORMANCE_HELP = 'Displays performance timing data for successful commands'
4 changes: 3 additions & 1 deletion edkrepo/commands/composite_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# SPDX-License-Identifier: BSD-2-Clause-Patent
#

from edkrepo.commands.edkrepo_command import VerboseArgument
from edkrepo.commands.edkrepo_command import VerboseArgument, PerformanceArgument


class CompositeCommand(object):
def __init__(self):
Expand All @@ -21,6 +22,7 @@ def get_metadata(self, command_name):
if command.get_metadata()['name'] == command_name:
metadata = command.get_metadata()
args = metadata['arguments']
args.append(PerformanceArgument)
args.append(VerboseArgument)
metadata['arguments'] = args
return metadata
Expand Down
7 changes: 6 additions & 1 deletion edkrepo/commands/edkrepo_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## @file
# edkrepo_command.py
#
# Copyright (c) 2017- 2019, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#

Expand Down Expand Up @@ -54,3 +54,8 @@ def run_command(self, args, config):
'required' : False,
'action' : 'store',
'help-text' : arguments.SOURCE_MANIFEST_REPO_HELP}

PerformanceArgument = {'name': 'performance',
'positional': False,
'required': False,
'help-text': arguments.PERFORMANCE_HELP}
4 changes: 4 additions & 0 deletions edkrepo/edkrepo_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import inspect
import imp
import importlib.util
import datetime as dt

from git.exc import GitCommandError

Expand Down Expand Up @@ -157,6 +158,7 @@ def generate_command_completion_script(script_filename, parser):
f.write(' complete -F _edkrepo_completions edkrepo\nfi\n')

def main():
start_time = dt.datetime.now()
command = command_factory.create_composite_command()
config = {}
try:
Expand Down Expand Up @@ -207,6 +209,8 @@ def main():
traceback.print_exc()
print("Error: {}".format(str(e)))
return 1
if parsed_args.performance:
print('\nExecution Time: {}'.format(dt.datetime.now() - start_time))
return 0

if __name__ == "__main__":
Expand Down

0 comments on commit 51eed87

Please sign in to comment.