size-metrics.scm 803 B

1234567891011121314151617181920212223242526
  1. (use-modules (hoot compile)
  2. (rnrs bytevectors)
  3. (wasm assemble))
  4. (define (write-size-metric name bytes)
  5. (format #t "wasm_binary_size{name=~s} ~a\n" name (round (/ bytes 1024))))
  6. (define* (measure-size name #:key import-abi? export-abi?)
  7. (define src 42) ; very simple program
  8. (write-size-metric name
  9. (bytevector-length
  10. (assemble-wasm
  11. (compile src
  12. #:import-abi? import-abi?
  13. #:export-abi? export-abi?)))))
  14. (display "
  15. # TYPE wasm_binary_size summary
  16. # UNIT wasm_binary_size KiB
  17. # HELP wasm_binary_size Size of Wasm binary
  18. ")
  19. (measure-size "import-abi" #:import-abi? #t)
  20. (measure-size "main")
  21. (measure-size "main-export-abi" #:export-abi? #t)