|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright (C) 2019 Intel Corporation. All rights reserved. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | + |
| 6 | +libsodium_CASES="aead_aes256gcm2 aead_aes256gcm aead_chacha20poly13052 aead_chacha20poly1305 \ |
| 7 | + aead_xchacha20poly1305 auth2 auth3 auth5 auth6 auth7 auth box2 box7 box8 \ |
| 8 | + box_easy2 box_easy box_seal box_seed box chacha20 codecs core1 core2 core3 \ |
| 9 | + core4 core5 core6 core_ed25519 core_ristretto255 ed25519_convert generichash2 \ |
| 10 | + generichash3 generichash hash3 hash kdf keygen kx metamorphic misuse \ |
| 11 | + onetimeauth2 onetimeauth7 onetimeauth pwhash_argon2id pwhash_argon2i \ |
| 12 | + pwhash_scrypt_ll pwhash_scrypt randombytes scalarmult2 scalarmult5 \ |
| 13 | + scalarmult6 scalarmult7 scalarmult8 scalarmult_ed25519 scalarmult_ristretto255 \ |
| 14 | + scalarmult secretbox2 secretbox7 secretbox8 secretbox_easy2 secretbox_easy \ |
| 15 | + secretbox secretstream shorthash sign siphashx24 sodium_core sodium_utils2 \ |
| 16 | + sodium_utils3 sodium_utils sodium_version stream2 stream3 stream4 stream verify1 \ |
| 17 | + xchacha20" |
| 18 | + |
| 19 | +readonly OUT_DIR=$PWD/libsodium/zig-out/bin |
| 20 | +readonly REPORT=$PWD/report.txt |
| 21 | +readonly IWASM_CMD=$PWD/../../../product-mini/platforms/linux/build/iwasm |
| 22 | + |
| 23 | +BENCH_NAME_MAX_LEN=20 |
| 24 | + |
| 25 | +rm -f $REPORT |
| 26 | +touch $REPORT |
| 27 | + |
| 28 | +function print_bench_name() |
| 29 | +{ |
| 30 | + name=$1 |
| 31 | + echo -en "$name" >> $REPORT |
| 32 | + name_len=${#name} |
| 33 | + if [ $name_len -lt $BENCH_NAME_MAX_LEN ] |
| 34 | + then |
| 35 | + spaces=$(( $BENCH_NAME_MAX_LEN - $name_len )) |
| 36 | + for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done |
| 37 | + fi |
| 38 | +} |
| 39 | + |
| 40 | +# run benchmarks |
| 41 | +cd $OUT_DIR |
| 42 | + |
| 43 | +echo -en "\t\t\t\t\t\tnative\tiwasm-aot\n" >> $REPORT |
| 44 | + |
| 45 | +for t in $libsodium_CASES |
| 46 | +do |
| 47 | + print_bench_name $t |
| 48 | + |
| 49 | + echo "run $t with native..." |
| 50 | + echo -en "\t" >> $REPORT |
| 51 | + ./${t} | awk -F '-' 'BEGIN{FIELDWIDTHS="10"}{ORS=""; print $1 / 1000000.0}' >> $REPORT |
| 52 | + |
| 53 | + echo "run $t with iwasm aot..." |
| 54 | + echo -en "\t \t" >> $REPORT |
| 55 | + $IWASM_CMD ${t}.aot | awk -F '-' 'BEGIN{FIELDWIDTHS="10"}{ORS=""; print $1 / 1000000.0}' >> $REPORT |
| 56 | + |
| 57 | + echo -en "\n" >> $REPORT |
| 58 | +done |
| 59 | + |
0 commit comments