Skip to content

Commit b3f450e

Browse files
wip: more benchmarking comments
1 parent 50a9fa9 commit b3f450e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
"cwd": "${workspaceFolder}",
5050
"env": {
5151
"_ARGCOMPLETE": "1",
52-
"COMP_LINE": "az vm ",
53-
"COMP_POINT": "6",
52+
"COMP_LINE": "az ",
53+
"COMP_POINT": "3",
5454
"_ARGCOMPLETE_SUPPRESS_SPACE": "0",
5555
"_ARGCOMPLETE_IFS": "\n",
5656
"_ARGCOMPLETE_SHELL": "powershell",

src/azure-cli-core/azure/cli/core/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,16 @@ def _get_extension_suppressions(mod_loaders):
422422
self.command_table.clear()
423423

424424
# Import announced breaking changes in azure.cli.core._breaking_change.py
425+
import time
426+
t1 = time.time()
425427
import_core_breaking_changes()
428+
print(f"[PERF] Breaking changes import: {time.time()-t1:.3f}s", file=sys.stderr, flush=True)
426429

427430
command_index = None
428431
# Set fallback=False to turn off command index in case of regression
432+
t1 = time.time()
429433
use_command_index = self.cli_ctx.config.getboolean('core', 'use_command_index', fallback=True)
430-
print(f"[PERF] use_command_index: {use_command_index}, args: {args}", file=sys.stderr, flush=True)
434+
print(f"[PERF] use_command_index: {use_command_index}, args: {args}, lookup time: {time.time()-t1:.3f}s", file=sys.stderr, flush=True)
431435
if use_command_index:
432436
command_index = CommandIndex(self.cli_ctx)
433437
index_result = command_index.get(args)
@@ -495,16 +499,25 @@ def _get_extension_suppressions(mod_loaders):
495499

496500
# No module found from the index. Load all command modules and extensions
497501
logger.debug("Loading all modules and extensions")
502+
t1 = time.time()
503+
print(f"[PERF] Loading ALL modules (no index)", file=sys.stderr, flush=True)
498504
_update_command_table_from_modules(args)
505+
elapsed_all_modules = time.time() - t1
506+
print(f"[PERF] Loaded ALL modules in {elapsed_all_modules:.3f} seconds", file=sys.stderr, flush=True)
499507

508+
t1 = time.time()
500509
ext_suppressions = _get_extension_suppressions(self.loaders)
501510
# We always load extensions even if the appropriate module has been loaded
502511
# as an extension could override the commands already loaded.
503512
_update_command_table_from_extensions(ext_suppressions)
513+
elapsed_all_extensions = time.time() - t1
514+
print(f"[PERF] Loaded ALL extensions in {elapsed_all_extensions:.3f} seconds", file=sys.stderr, flush=True)
504515
logger.debug("Loaded %d groups, %d commands.", len(self.command_group_table), len(self.command_table))
505516

506517
if use_command_index:
518+
t1 = time.time()
507519
command_index.update(self.command_table)
520+
print(f"[PERF] Command index update: {time.time()-t1:.3f}s", file=sys.stderr, flush=True)
508521

509522
return self.command_table
510523

0 commit comments

Comments
 (0)