diff options
-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) |