run_wasm_bench 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. # Usage: ./run_wasm_bench [-z] [niters]
  3. # Use -z to benchmark the legacy zkp code; otherwise benchmark our sigma-rs code
  4. # niters defaults to 10
  5. # cd into the directory containing this script (from the bash faq 028)
  6. if [[ $BASH_SOURCE = */* ]]; then
  7. cd -- "${BASH_SOURCE%/*}/" || exit
  8. fi
  9. # See if we're benchmarking the legacy (zkp) code or our (sigma-rs) code
  10. if [ "$1" = "-z" ]; then
  11. shift
  12. loxdir="../application-lox-zkp"
  13. else
  14. loxdir="../application-lox"
  15. fi
  16. if [ "$1" = "" ]; then
  17. niters=10
  18. else
  19. niters="$1"
  20. fi
  21. cleanup() {
  22. echo "Cleaning up..."
  23. if [ "$rdsyspid" != "" ]; then
  24. kill $rdsyspid
  25. fi
  26. if [ "$webserverpid" != "" ]; then
  27. kill $webserverpid
  28. fi
  29. echo "Done"
  30. }
  31. trap cleanup EXIT SIGINT SIGTERM
  32. # Start the rdsys backend
  33. cd ../rdsys
  34. ./backend -config conf/config.json &
  35. rdsyspid=$!
  36. cd "$loxdir/crates/lox-wasm"
  37. # Touch the wasm files so that the zkp ones aren't used for the sigma-rs
  38. # benches or vice versa
  39. touch index.js index.html pkg/*
  40. # Start the web server, which will itself manage the lox distributor
  41. ../../../Scripts/wasm_server $niters &
  42. webserverpid=$!
  43. sleep 2
  44. echo
  45. echo "*******************"
  46. echo "Please visit http://127.0.0.1:8000/ in a wasm-capable web browser"
  47. echo "*******************"
  48. echo
  49. wait $webserverpid
  50. webserverpid=""
  51. ../../../Scripts/wasm_parser