summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-01-12 11:58:33 -0800
committerGitHub <noreply@github.com>2018-01-12 11:58:33 -0800
commitd9ef39df1139837df5d7f7294ca45b62e3e282aa (patch)
treed20c13fbfa4ee929b1ded6dce0ebd0f3cde0225e /test
parent2bdd116719017bf13d8d4bda37b81be1baf13b37 (diff)
downloadbinaryen-d9ef39df1139837df5d7f7294ca45b62e3e282aa.tar.gz
binaryen-d9ef39df1139837df5d7f7294ca45b62e3e282aa.tar.bz2
binaryen-d9ef39df1139837df5d7f7294ca45b62e3e282aa.zip
Function metrics pass (#1353)
Emits binary size and opcode counts for each function, which helps investigating what's taking up space in a wasm binary.
Diffstat (limited to 'test')
-rw-r--r--test/passes/func-metrics.txt93
-rw-r--r--test/passes/func-metrics.wast56
-rw-r--r--test/passes/metrics.txt6
3 files changed, 152 insertions, 3 deletions
diff --git a/test/passes/func-metrics.txt b/test/passes/func-metrics.txt
new file mode 100644
index 000000000..c9b77eeaa
--- /dev/null
+++ b/test/passes/func-metrics.txt
@@ -0,0 +1,93 @@
+global
+ [funcs] : 3
+ [memory-data] : 9
+ [table-data] : 3
+ [total] : 18
+ const : 3
+func: empty
+ [binary-bytes] : 3
+ [total] : 4
+ [vars] : 0
+ nop : 1
+func: small
+ [binary-bytes] : 9
+ [total] : 14
+ [vars] : 0
+ block : 1
+ const : 1
+ drop : 1
+ nop : 1
+ return : 1
+func: ifs
+ [binary-bytes] : 51
+ [total] : 76
+ [vars] : 1
+ binary : 1
+ block : 1
+ const : 12
+ drop : 6
+ if : 4
+(module
+ (type $0 (func (param i32)))
+ (type $1 (func))
+ (global $glob i32 (i32.const 1337))
+ (table 256 256 anyfunc)
+ (elem (i32.const 0) $ifs $ifs $ifs)
+ (memory $0 256 256)
+ (data (i32.const 0) "\ff\ef\0f\1f 0@P\99")
+ (func $empty (; 0 ;) (type $1)
+ (nop)
+ )
+ (func $small (; 1 ;) (type $1)
+ (nop)
+ (drop
+ (i32.const 100421)
+ )
+ (return)
+ )
+ (func $ifs (; 2 ;) (type $0) (param $x i32)
+ (local $y f32)
+ (block $block0
+ (if
+ (i32.const 0)
+ (drop
+ (i32.const 1)
+ )
+ )
+ (if
+ (i32.const 0)
+ (drop
+ (i32.const 1)
+ )
+ (drop
+ (i32.const 2)
+ )
+ )
+ (if
+ (i32.const 4)
+ (drop
+ (i32.const 5)
+ )
+ (drop
+ (i32.const 6)
+ )
+ )
+ (drop
+ (i32.eq
+ (if (result i32)
+ (i32.const 4)
+ (i32.const 5)
+ (i32.const 6)
+ )
+ (i32.const 177)
+ )
+ )
+ )
+ )
+)
+global
+ [funcs] : 0
+ [total] : 0
+(module
+ (memory $0 0)
+)
diff --git a/test/passes/func-metrics.wast b/test/passes/func-metrics.wast
new file mode 100644
index 000000000..9c2f35a81
--- /dev/null
+++ b/test/passes/func-metrics.wast
@@ -0,0 +1,56 @@
+(module
+ (memory 256 256)
+ (table 256 256 anyfunc)
+ (elem (i32.const 0) $ifs $ifs $ifs)
+ (data (i32.const 0) "\ff\ef\0f\1f\20\30\40\50\99")
+ (type $0 (func (param i32)))
+ (global $glob i32 (i32.const 1337))
+ (func $empty)
+ (func $small
+ (nop)
+ (drop (i32.const 100421))
+ (return)
+ )
+ (func $ifs (type $0) (param $x i32)
+ (local $y f32)
+ (block $block0
+ (if
+ (i32.const 0)
+ (drop
+ (i32.const 1)
+ )
+ )
+ (if
+ (i32.const 0)
+ (drop
+ (i32.const 1)
+ )
+ (drop
+ (i32.const 2)
+ )
+ )
+ (if
+ (i32.const 4)
+ (drop
+ (i32.const 5)
+ )
+ (drop
+ (i32.const 6)
+ )
+ )
+ (drop
+ (i32.eq
+ (if (result i32)
+ (i32.const 4)
+ (i32.const 5)
+ (i32.const 6)
+ )
+ (i32.const 177)
+ )
+ )
+ )
+ )
+)
+;; module with no table or memory or anything for that matter
+(module
+)
diff --git a/test/passes/metrics.txt b/test/passes/metrics.txt
index 9041f36fe..f2670c550 100644
--- a/test/passes/metrics.txt
+++ b/test/passes/metrics.txt
@@ -1,8 +1,8 @@
-Counts
+total
[funcs] : 1
[memory-data] : 9
[table-data] : 3
- [total] : 27
+ [total] : 41
[vars] : 1
binary : 1
block : 1
@@ -56,7 +56,7 @@ Counts
)
)
)
-Counts
+total
[funcs] : 0
[total] : 0
[vars] : 0