My output is different:

===
func: _mesh_draw
  [binary-bytes] : 143     
  [total]        : 62      
  [vars]         : 1       
  binary         : 3       
  block          : 1       
  call           : 7       
  const          : 21      
  get_local      : 13      
  load           : 7       
  set_local      : 10
===

All my function names are prefixed with an underscore, and none have the 
"removable-bytes-without-it" category that is visible in your example ... I 
also get an error at the end of the process:

===
wasm-opt: 
/home/goran/apps/emsdk/binaryen/tag-1.38.20/src/wasm-traversal.h:370: void 
wasm::Walker<SubType, VisitorType>::pushTask(wasm::Walker<SubType, 
VisitorType>::TaskFunc, wasm::Expression**) [with SubType = 
wasm::ReachabilityAnalyzer; VisitorType = 
wasm::Visitor<wasm::ReachabilityAnalyzer, void>; wasm::Walker<SubType, 
VisitorType>::TaskFunc = void (*)(wasm::ReachabilityAnalyzer*, 
wasm::Expression**)]: Assertion `*currp' failed.
Aborted (core dumped)
===

But, since the number of "func" entries matches the "funcs" listed in the 
"global" section, I assume it's just some unmet terminal condition that has 
no effect on the validity of the already generated output ...

I guess I could use this, in combination with the wast file, to write my 
own tool ... "binary-bytes" is the size of the function in bytes, right? 

On Wednesday, February 6, 2019 at 11:34:19 AM UTC-5, caiiiycuk wrote:
>
> Hi. I think that best way to do it is to use wasm-opt from binaryen 
> (thanks to Alon, hi told me how to do this): 
>
> bin/wasm-opt --func-metrics test/hello_world.wast 
> == 
> global 
>  [funcs]        : 1 
> func: add 
>  [binary-bytes] : 7 
>  [total]        : 3 
>  binary         : 1 
>  local.get      : 2 
> export: add (add) 
>  [removable-bytes-without-it]: 48 
>
> That prints out per-function metrics, in particular the last part 
> computes how much the wasm could be optimized down if the function 
> were not there. So it measures not just the function size but how much 
> it "holds on to" in the rest of the wasm, that can otherwise be 
> removed (it measures that by removing it, running the full optimizer, 
> and seeing how much is left). It's easy to extend it to do other 
> related things (see src/passes/Metrics.cpp) 
> == 
>
> So, for example in linux environment you can do something like: 
> bin/wasm-opt --func-metrics test/hello_world.wast | grep "func: 
> <func-name>" -A1 
>
> For better linking, I get this from 
> https://groups.google.com/forum/#!topic/emscripten-discuss/NCO4LxMbsg0 
>
>
> > 
> > Ideally, a program that would take the name of a C function as input, 
> and output the number of bytes that the specified function contributes to 
> the final wasm file, along with the number of bytes that it contributes to 
> the final js file. 
> > 
> > I rewrote my application to use functions provided in html5.h, instead 
> of relying on SDL, and this resulted in significant size savings. So, if I 
> could have more insight into the overall weight of specific functions, I 
> could probably craft similarly thin alternatives, which could significantly 
> improve both download and start-up speeds (especially on mobile devices). 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "emscripten-discuss" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>. 
>
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to