From 5078d4daffb39edb91785e5fd6d28c5ff92478e4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 30 Jul 2024 14:29:28 -0700 Subject: Add a customizable title to Metrics reporting (#6792) Before the PR: $ bin/wasm-opt test/hello_world.wat --metrics total [exports] : 1 [funcs] : 1 [globals] : 0 [imports] : 0 [memories] : 1 [memory-data] : 0 [tables] : 0 [tags] : 0 [total] : 3 [vars] : 0 Binary : 1 LocalGet : 2 After the PR: $ bin/wasm-opt test/hello_world.wat --metrics Metrics total [exports] : 1 [funcs] : 1 ... Note the "Metrics" addition at the top. And the title can be customized: $ bin/wasm-opt test/hello_world.wat --metrics=text Metrics: text total [exports] : 1 [funcs] : 1 The custom title can be helpful when multiple invocations of metrics are used at once, e.g. --metrics=before -O3 --metrics=after. --- src/passes/pass.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/passes/pass.cpp') diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index ec6077941..3f84ee604 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -275,7 +275,9 @@ void PassRegistry::registerPasses() { createMergeSimilarFunctionsPass); registerPass( "merge-locals", "merges locals when beneficial", createMergeLocalsPass); - registerPass("metrics", "reports metrics", createMetricsPass); + registerPass("metrics", + "reports metrics (with an optional title, --metrics[=TITLE])", + createMetricsPass); registerPass("minify-imports", "minifies import names (only those, and not export names), and " "emits a mapping to the minified ones", -- cgit v1.2.3