diff options
author | Alon Zakai <azakai@google.com> | 2024-07-30 14:29:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-30 14:29:28 -0700 |
commit | 5078d4daffb39edb91785e5fd6d28c5ff92478e4 (patch) | |
tree | 5adbde78501e079d8c2d0a40ea4a52f3046fa822 /src | |
parent | e2f666adbae7d5d431e3521ede5d9dd828f0cd97 (diff) | |
download | binaryen-5078d4daffb39edb91785e5fd6d28c5ff92478e4.tar.gz binaryen-5078d4daffb39edb91785e5fd6d28c5ff92478e4.tar.bz2 binaryen-5078d4daffb39edb91785e5fd6d28c5ff92478e4.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Metrics.cpp | 7 | ||||
-rw-r--r-- | src/passes/pass.cpp | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/passes/Metrics.cpp b/src/passes/Metrics.cpp index 1778eb9bd..186d7e695 100644 --- a/src/passes/Metrics.cpp +++ b/src/passes/Metrics.cpp @@ -45,6 +45,13 @@ struct Metrics } void doWalkModule(Module* module) { + std::string title = getArgumentOrDefault("metrics", ""); + std::cout << "Metrics"; + if (!title.empty()) { + std::cout << ": " << title; + } + std::cout << '\n'; + ImportInfo imports(*module); // global things 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", |