summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/Metrics.cpp3
-rw-r--r--test/passes/O3_low-memory-unused_metrics.txt3
-rw-r--r--test/passes/converge_O3_metrics.bin.txt3
-rw-r--r--test/passes/func-metrics.txt27
-rw-r--r--test/passes/metrics.txt7
-rw-r--r--test/passes/metrics_strip-debug_metrics.bin.txt6
-rw-r--r--test/passes/metrics_strip-producers_metrics.bin.txt6
7 files changed, 54 insertions, 1 deletions
diff --git a/src/passes/Metrics.cpp b/src/passes/Metrics.cpp
index b794ea32d..8717a86b7 100644
--- a/src/passes/Metrics.cpp
+++ b/src/passes/Metrics.cpp
@@ -66,6 +66,7 @@ struct Metrics : public WalkerPass<PostWalker<Metrics, UnifiedExpressionVisitor<
counts["[imports]"] = imports.getNumImports();
// add functions
counts["[funcs]"] = imports.getNumDefinedFunctions();
+ counts["[exports]"] = module->exports.size();
// add memory and table
if (module->memory.exists) {
Index size = 0;
@@ -172,7 +173,7 @@ struct Metrics : public WalkerPass<PostWalker<Metrics, UnifiedExpressionVisitor<
o << title << "\n";
for (auto* key : keys) {
auto value = counts[key];
- if (value == 0) continue;
+ if (value == 0 && key[0] != '[') continue;
o << " " << left << setw(15) << key << ": " << setw(8)
<< value;
if (lastCounts.count(key)) {
diff --git a/test/passes/O3_low-memory-unused_metrics.txt b/test/passes/O3_low-memory-unused_metrics.txt
index 0978d3715..39a0155c0 100644
--- a/test/passes/O3_low-memory-unused_metrics.txt
+++ b/test/passes/O3_low-memory-unused_metrics.txt
@@ -1,6 +1,9 @@
total
+ [exports] : 1
[funcs] : 1
[imports] : 2
+ [memory-data] : 0
+ [table-data] : 0
[total] : 1601
[vars] : 13
binary : 213
diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt
index be1ebb897..00835cc1e 100644
--- a/test/passes/converge_O3_metrics.bin.txt
+++ b/test/passes/converge_O3_metrics.bin.txt
@@ -1,4 +1,5 @@
total
+ [exports] : 2
[funcs] : 8
[imports] : 3
[memory-data] : 28
@@ -240,6 +241,7 @@ total
)
)
total
+ [exports] : 2
[funcs] : 8
[imports] : 3
[memory-data] : 28
@@ -482,6 +484,7 @@ total
)
)
total
+ [exports] : 2
[funcs] : 8
[imports] : 3
[memory-data] : 28
diff --git a/test/passes/func-metrics.txt b/test/passes/func-metrics.txt
index 2d70c07c9..fd8d949bd 100644
--- a/test/passes/func-metrics.txt
+++ b/test/passes/func-metrics.txt
@@ -1,5 +1,7 @@
global
+ [exports] : 0
[funcs] : 3
+ [imports] : 0
[memory-data] : 9
[table-data] : 3
[total] : 3
@@ -7,10 +9,12 @@ global
func: empty
[binary-bytes] : 3
[total] : 1
+ [vars] : 0
nop : 1
func: small
[binary-bytes] : 9
[total] : 5
+ [vars] : 0
block : 1
const : 1
drop : 1
@@ -84,30 +88,41 @@ func: ifs
)
)
global
+ [exports] : 0
+ [funcs] : 0
+ [imports] : 0
+ [total] : 0
(module
)
global
+ [exports] : 2
[funcs] : 3
[imports] : 1
+ [total] : 0
func: func_a
[binary-bytes] : 16
[total] : 8
+ [vars] : 0
block : 1
call : 7
func: func_b
[binary-bytes] : 22
[total] : 11
+ [vars] : 0
block : 1
call : 10
func: func_c
[binary-bytes] : 32
[total] : 16
+ [vars] : 0
block : 1
call : 15
export: a (func_a)
[removable-bytes-without-it]: 72
+ [total] : 0
export: b (func_b)
[removable-bytes-without-it]: 18
+ [total] : 0
(module
(type $FUNCSIG$v (func))
(import "env" "waka" (func $waka))
@@ -153,17 +168,22 @@ export: b (func_b)
)
)
global
+ [exports] : 1
[funcs] : 1
[imports] : 1
+ [total] : 0
func: func_a
[binary-bytes] : 12
[total] : 6
+ [vars] : 0
block : 1
call : 5
export: a (func_a)
[removable-bytes-without-it]: 7
+ [total] : 0
start: func_a
[removable-bytes-without-it]: 3
+ [total] : 0
(module
(type $FUNCSIG$v (func))
(import "env" "waka" (func $waka))
@@ -178,15 +198,19 @@ start: func_a
)
)
global
+ [exports] : 0
[funcs] : 1
[imports] : 1
+ [total] : 0
func: func_a
[binary-bytes] : 12
[total] : 6
+ [vars] : 0
block : 1
call : 5
start: func_a
[removable-bytes-without-it]: 67
+ [total] : 0
(module
(type $FUNCSIG$v (func))
(import "env" "waka" (func $waka))
@@ -200,6 +224,7 @@ start: func_a
)
)
global
+ [exports] : 1
[funcs] : 1
[imports] : 1
[total] : 1
@@ -207,9 +232,11 @@ global
func: 0
[binary-bytes] : 4
[total] : 1
+ [vars] : 0
global.get : 1
export: stackSave (0)
[removable-bytes-without-it]: 74
+ [total] : 0
(module
(type $0 (func (result i32)))
(import "env" "STACKTOP" (global $gimport$0 i32))
diff --git a/test/passes/metrics.txt b/test/passes/metrics.txt
index 216ac1fcb..096194e84 100644
--- a/test/passes/metrics.txt
+++ b/test/passes/metrics.txt
@@ -1,5 +1,7 @@
total
+ [exports] : 0
[funcs] : 1
+ [imports] : 0
[memory-data] : 9
[table-data] : 3
[total] : 27
@@ -57,5 +59,10 @@ total
)
)
total
+ [exports] : 0
+ [funcs] : 0
+ [imports] : 0
+ [total] : 0
+ [vars] : 0
(module
)
diff --git a/test/passes/metrics_strip-debug_metrics.bin.txt b/test/passes/metrics_strip-debug_metrics.bin.txt
index dbb3dcc37..0efad35f5 100644
--- a/test/passes/metrics_strip-debug_metrics.bin.txt
+++ b/test/passes/metrics_strip-debug_metrics.bin.txt
@@ -1,10 +1,16 @@
total
+ [exports] : 1
[funcs] : 1
+ [imports] : 0
[total] : 1
+ [vars] : 0
nop : 1
total
+ [exports] : 1
[funcs] : 1
+ [imports] : 0
[total] : 1
+ [vars] : 0
nop : 1
(module
(type $0 (func))
diff --git a/test/passes/metrics_strip-producers_metrics.bin.txt b/test/passes/metrics_strip-producers_metrics.bin.txt
index 6ddfa5892..e630c14b7 100644
--- a/test/passes/metrics_strip-producers_metrics.bin.txt
+++ b/test/passes/metrics_strip-producers_metrics.bin.txt
@@ -1,10 +1,16 @@
total
+ [exports] : 1
[funcs] : 1
+ [imports] : 0
[total] : 1
+ [vars] : 0
nop : 1
total
+ [exports] : 1
[funcs] : 1
+ [imports] : 0
[total] : 1
+ [vars] : 0
nop : 1
(module
(type $0 (func))