run_wasm_bench 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. my_ip=`ip addr show dev eth0 | grep -Po 'inet \K(\d+\.\d+\.\d+\.\d+)'`
  44. sleep 2
  45. echo
  46. echo "*******************"
  47. echo "Please visit http://$my_ip:8000/ in a wasm-capable web browser"
  48. echo "*******************"
  49. echo
  50. wait $webserverpid
  51. webserverpid=""
  52. ../../../Scripts/wasm_parser