run_interp.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. CUR_DIR=$PWD
  5. OUT_DIR=$CUR_DIR/out
  6. REPORT=$CUR_DIR/report.txt
  7. TIME=/usr/bin/time
  8. PLATFORM=$(uname -s | tr A-Z a-z)
  9. IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
  10. BENCH_NAME_MAX_LEN=20
  11. SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \
  12. nestedloop2 nestedloop3 random seqhash sieve strchr \
  13. switch2"
  14. rm -f $REPORT
  15. touch $REPORT
  16. function print_bench_name()
  17. {
  18. name=$1
  19. echo -en "$name" >> $REPORT
  20. name_len=${#name}
  21. if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
  22. then
  23. spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
  24. for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
  25. fi
  26. }
  27. echo "Start to run cases, the result is written to report.txt"
  28. #run benchmarks
  29. cd $OUT_DIR
  30. echo -en "\t\t\t\t\t native\tiwasm-interp\n" >> $REPORT
  31. for t in $SHOOTOUT_CASES
  32. do
  33. print_bench_name $t
  34. echo "run $t with native .."
  35. echo -en "\t" >> $REPORT
  36. $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
  37. echo "run $t with iwasm interp .."
  38. echo -en "\t" >> $REPORT
  39. $TIME -f "real-%e-time" $IWASM_CMD ${t}.wasm 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
  40. echo -en "\n" >> $REPORT
  41. done