Skip to content

Commit 1dd37de

Browse files
authored
Add globals to metrics (#2110)
1 parent 8c30cd1 commit 1dd37de

7 files changed

Lines changed: 18 additions & 2 deletions

src/passes/Metrics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ struct Metrics
6262
walkTable(&module->table);
6363
walkMemory(&module->memory);
6464

65-
// add imports
65+
// add imports / funcs / globals/ exports
6666
counts["[imports]"] = imports.getNumImports();
67-
// add functions
6867
counts["[funcs]"] = imports.getNumDefinedFunctions();
68+
counts["[globals]"] = imports.getNumDefinedGlobals();
6969
counts["[exports]"] = module->exports.size();
7070
// add memory and table
7171
if (module->memory.exists) {

test/passes/O3_low-memory-unused_metrics.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
total
22
[exports] : 1
33
[funcs] : 1
4+
[globals] : 0
45
[imports] : 10
56
[memory-data] : 0
67
[table-data] : 0

test/passes/converge_O3_metrics.bin.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
total
22
[exports] : 2
33
[funcs] : 8
4+
[globals] : 1
45
[imports] : 3
56
[memory-data] : 28
67
[table-data] : 429
@@ -243,6 +244,7 @@ total
243244
total
244245
[exports] : 2
245246
[funcs] : 8
247+
[globals] : 1
246248
[imports] : 3
247249
[memory-data] : 28
248250
[table-data] : 429
@@ -486,6 +488,7 @@ total
486488
total
487489
[exports] : 2
488490
[funcs] : 8
491+
[globals] : 1
489492
[imports] : 3
490493
[memory-data] : 28
491494
[table-data] : 429

test/passes/func-metrics.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
global
22
[exports] : 0
33
[funcs] : 3
4+
[globals] : 1
45
[imports] : 0
56
[memory-data] : 9
67
[table-data] : 3
@@ -90,13 +91,15 @@ func: ifs
9091
global
9192
[exports] : 0
9293
[funcs] : 0
94+
[globals] : 0
9395
[imports] : 0
9496
[total] : 0
9597
(module
9698
)
9799
global
98100
[exports] : 2
99101
[funcs] : 3
102+
[globals] : 0
100103
[imports] : 1
101104
[total] : 0
102105
func: func_a
@@ -170,6 +173,7 @@ export: b (func_b)
170173
global
171174
[exports] : 1
172175
[funcs] : 1
176+
[globals] : 0
173177
[imports] : 1
174178
[total] : 0
175179
func: func_a
@@ -200,6 +204,7 @@ start: func_a
200204
global
201205
[exports] : 0
202206
[funcs] : 1
207+
[globals] : 0
203208
[imports] : 1
204209
[total] : 0
205210
func: func_a
@@ -226,6 +231,7 @@ start: func_a
226231
global
227232
[exports] : 1
228233
[funcs] : 1
234+
[globals] : 1
229235
[imports] : 1
230236
[total] : 1
231237
global.get : 1

test/passes/metrics.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
total
22
[exports] : 0
33
[funcs] : 1
4+
[globals] : 1
45
[imports] : 0
56
[memory-data] : 9
67
[table-data] : 3
@@ -61,6 +62,7 @@ total
6162
total
6263
[exports] : 0
6364
[funcs] : 0
65+
[globals] : 0
6466
[imports] : 0
6567
[total] : 0
6668
[vars] : 0

test/passes/metrics_strip-debug_metrics.bin.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
total
22
[exports] : 1
33
[funcs] : 1
4+
[globals] : 0
45
[imports] : 0
56
[total] : 1
67
[vars] : 0
78
nop : 1
89
total
910
[exports] : 1
1011
[funcs] : 1
12+
[globals] : 0
1113
[imports] : 0
1214
[total] : 1
1315
[vars] : 0

test/passes/metrics_strip-producers_metrics.bin.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
total
22
[exports] : 1
33
[funcs] : 1
4+
[globals] : 0
45
[imports] : 0
56
[total] : 1
67
[vars] : 0
78
nop : 1
89
total
910
[exports] : 1
1011
[funcs] : 1
12+
[globals] : 0
1113
[imports] : 0
1214
[total] : 1
1315
[vars] : 0

0 commit comments

Comments
 (0)