run_aot.sh 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. libsodium_CASES="aead_aes256gcm2 aead_aes256gcm aead_chacha20poly13052 aead_chacha20poly1305 \
  5. aead_xchacha20poly1305 auth2 auth3 auth5 auth6 auth7 auth box2 box7 box8 \
  6. box_easy2 box_easy box_seal box_seed box chacha20 codecs core1 core2 core3 \
  7. core4 core5 core6 core_ed25519 core_ristretto255 ed25519_convert generichash2 \
  8. generichash3 generichash hash3 hash kdf keygen kx metamorphic misuse \
  9. onetimeauth2 onetimeauth7 onetimeauth pwhash_argon2id pwhash_argon2i \
  10. pwhash_scrypt_ll pwhash_scrypt randombytes scalarmult2 scalarmult5 \
  11. scalarmult6 scalarmult7 scalarmult8 scalarmult_ed25519 scalarmult_ristretto255 \
  12. scalarmult secretbox2 secretbox7 secretbox8 secretbox_easy2 secretbox_easy \
  13. secretbox secretstream_xchacha20poly1305 shorthash sign siphashx24 sodium_core \
  14. sodium_utils2 sodium_utils stream2 stream3 stream4 stream verify1 xchacha20"
  15. PLATFORM=$(uname -s | tr A-Z a-z)
  16. readonly OUT_DIR=$PWD/libsodium/zig-out/bin
  17. readonly REPORT=$PWD/report.txt
  18. readonly IWASM_CMD=$PWD/../../../product-mini/platforms/${PLATFORM}/build/iwasm
  19. readonly TIME=/usr/bin/time
  20. BENCH_NAME_MAX_LEN=20
  21. rm -f $REPORT
  22. touch $REPORT
  23. function print_bench_name()
  24. {
  25. name=$1
  26. echo -en "$name" >> $REPORT
  27. name_len=${#name}
  28. if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
  29. then
  30. spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
  31. for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
  32. fi
  33. }
  34. # run benchmarks
  35. cd $OUT_DIR
  36. if [[ ${PLATFORM} == "linux" ]]; then
  37. echo -en "\t\t\t\t\t\tnative\tiwasm-aot\tiwasm-aot-segue\n" >> $REPORT
  38. else
  39. echo -en "\t\t\t\t\t\tnative\tiwasm-aot\n" >> $REPORT
  40. fi
  41. for t in $libsodium_CASES
  42. do
  43. print_bench_name $t
  44. echo "run $t with native..."
  45. echo -en "\t" >> $REPORT
  46. if [[ $t != "sodium_utils2" ]]; then
  47. ./${t} | awk '{printf "%-10.2f", $0/1000000.0}' >> $REPORT
  48. else
  49. # sodium_utils2 doesn't print the result,
  50. # use time command to get result instead
  51. $TIME -f "real-%e-time" ./${t} 2>&1 | grep "real-.*-time" |
  52. awk -F '-' '{printf "%-10.2f", $2}' >> $REPORT
  53. fi
  54. echo "run $t with iwasm aot..."
  55. echo -en "\t \t" >> $REPORT
  56. if [[ $t != "sodium_utils2" ]]; then
  57. $IWASM_CMD ${t}.aot | awk '{printf "%-10.2f", $0/1000000.0}' >> $REPORT
  58. else
  59. # sodium_utils2 doesn't print the result,
  60. # use time command to get result instead
  61. $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" |
  62. awk -F '-' '{printf "%-10.2f", $2}' >> $REPORT
  63. fi
  64. if [[ ${PLATFORM} == "linux" ]]; then
  65. echo "run $t with iwasm aot segue..."
  66. echo -en "\t \t" >> $REPORT
  67. if [[ $t != "sodium_utils2" ]]; then
  68. $IWASM_CMD ${t}_segue.aot | awk '{printf "%.2f", $0/1000000.0}' >> $REPORT
  69. else
  70. # sodium_utils2 doesn't print the result,
  71. # use time command to get result instead
  72. $TIME -f "real-%e-time" $IWASM_CMD ${t}_segue.aot 2>&1 | grep "real-.*-time" |
  73. awk -F '-' '{printf "%.2f", $2}' >> $REPORT
  74. fi
  75. fi
  76. echo -en "\n" >> $REPORT
  77. done