diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-16 17:06:02 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-16 17:06:02 -0700 |
commit | 3a01c5d7d1f03fb88d249ca1ecca6325b77e799a (patch) | |
tree | 0d1654534909863047c575d169e0dd392100fd93 | |
parent | 70e761dd4e75f658797457c427e1388dd91f678a (diff) | |
download | binaryen-3a01c5d7d1f03fb88d249ca1ecca6325b77e799a.tar.gz binaryen-3a01c5d7d1f03fb88d249ca1ecca6325b77e799a.tar.bz2 binaryen-3a01c5d7d1f03fb88d249ca1ecca6325b77e799a.zip |
add total vars (non-param locals) to metrics
-rw-r--r-- | src/passes/Metrics.cpp | 8 | ||||
-rw-r--r-- | test/passes/metrics.txt | 4 | ||||
-rw-r--r-- | test/passes/metrics.wast | 3 |
3 files changed, 13 insertions, 2 deletions
diff --git a/src/passes/Metrics.cpp b/src/passes/Metrics.cpp index c18d1d7cd..a6d51adbf 100644 --- a/src/passes/Metrics.cpp +++ b/src/passes/Metrics.cpp @@ -44,8 +44,16 @@ struct Metrics : public WalkerPass<PostWalker<Metrics, UnifiedExpressionVisitor< keys.push_back(i.first); total += i.second; } + // add total keys.push_back("[total]"); counts["[total]"] = total; + // add vars + size_t vars = 0; + for (auto& func : module->functions) { + vars += func->getNumVars(); + } + keys.push_back("[vars]"); + counts["[vars]"] = vars; sort(keys.begin(), keys.end(), [](const char* a, const char* b) -> bool { return strcmp(b, a) > 0; }); diff --git a/test/passes/metrics.txt b/test/passes/metrics.txt index 5824a2769..e1f67c583 100644 --- a/test/passes/metrics.txt +++ b/test/passes/metrics.txt @@ -1,12 +1,14 @@ Counts [total] : 18 + [vars] : 1 binary : 1 block : 1 const : 12 if : 4 (module (memory 256 256) - (func $ifs + (func $ifs (param $x i32) + (local $y f32) (block $block0 (if (i32.const 0) diff --git a/test/passes/metrics.wast b/test/passes/metrics.wast index 138a8a206..67ad1fc5b 100644 --- a/test/passes/metrics.wast +++ b/test/passes/metrics.wast @@ -1,6 +1,7 @@ (module (memory 256 256) - (func $ifs + (func $ifs (param $x i32) + (local $y f32) (block (if (i32.const 0) |