Explorar o código

Add benchmarks (#979)

Add scripts to build and run benchmark of coremark, polybench,
sightglass and jetstream2. And add documents.
Wenyong Huang %!s(int64=4) %!d(string=hai) anos
pai
achega
4bc6074273

+ 19 - 0
tests/benchmarks/coremark/README.md

@@ -0,0 +1,19 @@
+# Introduction
+
+[CoreMark's](https://www.eembc.org/coremark) primary goals are simplicity and providing a method for testing only a processor's core features.
+
+**Source**: https://github.com/eembc/coremark
+
+# Building
+
+Please build iwasm and wamrc, refer to:
+- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos)
+- [build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler)
+
+And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`.
+
+And then run `./build.sh` to build the source code, file `coremark.exe`, `coremark.wasm` and `coremark.aot` will be generated.
+
+# Running
+
+Run `./run.sh` to test the benchmark, the native mode, iwasm aot mode and iwasm interpreter mode will be tested respectively.

+ 35 - 0
tests/benchmarks/coremark/build.sh

@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+WAMRC="../../../wamr-compiler/build/wamrc"
+
+if [ ! -d coremark ]; then
+    git clone https://github.com/eembc/coremark.git
+fi
+
+cd coremark
+
+echo "Build coremark with gcc .."
+gcc -O3 -Iposix -I. -DFLAGS_STR=\""-O3 -DPERFORMANCE_RUN=1  -lrt"\" \
+        -DITERATIONS=0 -DPERFORMANCE_RUN=1 \
+        core_list_join.c core_main.c core_matrix.c core_state.c \
+        core_util.c posix/core_portme.c \
+        -o ../coremark.exe -lrt
+
+echo "Build coremark with wasi-sdk .."
+/opt/wasi-sdk/bin/clang -O3 -Iposix -I. -DFLAGS_STR=\""-O3 -DPERFORMANCE_RUN=1"\" \
+        -Wl,--export=main \
+        -DITERATIONS=0 -DPERFORMANCE_RUN=1 \
+        -Wl,--allow-undefined \
+        core_list_join.c core_main.c core_matrix.c core_state.c \
+        core_util.c posix/core_portme.c \
+        -o ../coremark.wasm
+
+cd ..
+
+echo "Compile coremark.wasm to coremark.aot .."
+${WAMRC} -o coremark.aot coremark.wasm
+
+echo "Done"

+ 16 - 0
tests/benchmarks/coremark/run.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+IWASM="../../../product-mini/platforms/linux/build/iwasm"
+WAMRC="../../../wamr-compiler/build/wamrc"
+
+echo "Run coremark with native .."
+./coremark.exe
+
+echo "Run coremark with iwasm mode .."
+${IWASM} coremark.aot
+
+echo "Run coremakr with iwasm interpreter .."
+${IWASM} coremark.wasm

+ 29 - 0
tests/benchmarks/jetstream/README.md

@@ -0,0 +1,29 @@
+# Introduction
+
+[JetStream 2](https://browserbench.org/JetStream) is a JavaScript and WebAssembly benchmark suite focused on the most advanced web applications. It rewards browsers that start up quickly, execute code quickly, and run smoothly.
+
+**Source**: https://browserbench.org/JetStream/in-depth.html
+
+# Building
+
+Please build iwasm and wamrc, refer to:
+- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos)
+- [build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler)
+
+And install emsdk, refer to [the guide](https://emscripten.org/docs/getting_started/downloads.html). Don't forget to activate
+ emsdk and set up environment variables. For example, use instructions below to install it under /opt and activate it:
+``` bash
+$ cd /opt
+$ git clone https://github.com/emscripten-core/emsdk.git
+$ cd emsdk
+$ git pull
+$ ./emsdk install latest
+$ ./emsdk activate latest
+$ echo "source /opt/emsdk/emsdk_env.sh" >> "${HOME}"/.bashrc
+```
+
+And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it.
+
+# Running
+
+Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated.

+ 73 - 0
tests/benchmarks/jetstream/build.sh

@@ -0,0 +1,73 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+OUT_DIR=$PWD/out
+WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
+
+mkdir -p jetstream
+mkdir -p ${OUT_DIR}
+
+cd jetstream
+
+echo "Download source files .."
+wget https://browserbench.org/JetStream/wasm/gcc-loops.cpp
+wget https://browserbench.org/JetStream/wasm/quicksort.c
+wget https://browserbench.org/JetStream/wasm/HashSet.cpp
+wget https://browserbench.org/JetStream/simple/float-mm.c
+
+patch -p1 < ../jetstream.patch
+
+echo "Build gcc-loops with g++ .."
+g++ -O3 -msse2 -msse3 -msse4 -o ${OUT_DIR}/gcc-loops_native gcc-loops.cpp
+
+echo "Build gcc-loops with em++ .."
+em++ -O3 -s STANDALONE_WASM=1 -msimd128 \
+         -s INITIAL_MEMORY=1048576 \
+         -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=32768 \
+         -s "EXPORTED_FUNCTIONS=['_main']" \
+         -o ${OUT_DIR}/gcc-loops.wasm gcc-loops.cpp
+
+echo "Compile gcc-loops.wasm to gcc-loops.aot"
+${WAMRC_CMD} -o ${OUT_DIR}/gcc-loops.aot ${OUT_DIR}/gcc-loops.wasm
+
+echo "Build quicksort with gcc .."
+gcc -O3 -msse2 -msse3 -msse4 -o ${OUT_DIR}/quicksort_native quicksort.c
+
+echo "Build quicksort with emcc .."
+emcc -O3 -s STANDALONE_WASM=1 -msimd128 \
+         -s INITIAL_MEMORY=1048576 \
+         -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=32768 \
+         -s "EXPORTED_FUNCTIONS=['_main']" \
+         -o ${OUT_DIR}/quicksort.wasm quicksort.c
+
+echo "Compile quicksort.wasm to quicksort.aot"
+${WAMRC_CMD} -o ${OUT_DIR}/quicksort.aot ${OUT_DIR}/quicksort.wasm
+
+echo "Build HashSet with g++ .."
+g++ -O3 -msse2 -msse3 -msse4 -o ${OUT_DIR}/HashSet_native HashSet.cpp \
+        -lstdc++
+
+echo "Build HashSet with em++ .."
+em++ -O3 -s STANDALONE_WASM=1 -msimd128 \
+         -s INITIAL_MEMORY=1048576 \
+         -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=32768 \
+         -s "EXPORTED_FUNCTIONS=['_main']" \
+         -o ${OUT_DIR}/HashSet.wasm HashSet.cpp
+
+echo "Compile HashSet.wasm to HashSet.aot"
+${WAMRC_CMD} -o ${OUT_DIR}/HashSet.aot ${OUT_DIR}/HashSet.wasm
+
+echo "Build float-mm with gcc .."
+gcc -O3 -msse2 -msse3 -msse4 -o ${OUT_DIR}/float-mm_native float-mm.c
+
+echo "Build float-mm with emcc .."
+emcc -O3 -s STANDALONE_WASM=1 -msimd128 \
+         -s INITIAL_MEMORY=1048576 \
+         -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=32768 \
+         -s "EXPORTED_FUNCTIONS=['_main']" \
+         -o ${OUT_DIR}/float-mm.wasm float-mm.c
+
+echo "Compile float-mm.wasm to float-mm.aot"
+${WAMRC_CMD} -o ${OUT_DIR}/float-mm.aot ${OUT_DIR}/float-mm.wasm

+ 20 - 0
tests/benchmarks/jetstream/jetstream.patch

@@ -0,0 +1,20 @@
+diff -urN jetstream-org/HashSet.cpp jetstream/HashSet.cpp
+--- jetstream-org/HashSet.cpp	2020-10-30 04:12:42.000000000 +0800
++++ jetstream/HashSet.cpp	2022-01-24 17:11:08.619831711 +0800
+@@ -24,6 +24,7 @@
+ #include <memory>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include <sys/time.h>
+ 
+ // Compile with: xcrun clang++ -o HashSet HashSet.cpp -O2 -W -framework Foundation -licucore -std=c++11 -fvisibility=hidden -DNDEBUG=1
+@@ -76,7 +77,7 @@
+ inline ToType bitwise_cast(FromType from)
+ {
+     typename std::remove_const<ToType>::type to { };
+-    std::memcpy(&to, &from, sizeof(to));
++    memcpy(&to, &from, sizeof(to));
+     return to;
+ }
+ 

+ 52 - 0
tests/benchmarks/jetstream/run_aot.sh

@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+CUR_DIR=$PWD
+OUT_DIR=$CUR_DIR/out
+REPORT=$CUR_DIR/report.txt
+TIME=/usr/bin/time
+
+PLATFORM=$(uname -s | tr A-Z a-z)
+IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
+
+BENCH_NAME_MAX_LEN=20
+
+JETSTREAM_CASES="gcc-loops quicksort HashSet float-mm"
+
+rm -f $REPORT
+touch $REPORT
+
+function print_bench_name()
+{
+    name=$1
+    echo -en "$name" >> $REPORT
+    name_len=${#name}
+    if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
+    then
+        spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
+        for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
+    fi
+}
+
+echo "Start to run cases, the result is written to report.txt"
+
+#run benchmarks
+cd $OUT_DIR
+echo -en "\t\t\t\t\t  native\tiwasm-aot\n" >> $REPORT
+
+for t in $JETSTREAM_CASES
+do
+    print_bench_name $t
+
+    echo "run $t with native .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo "run $t with iwasm aot .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo -en "\n" >> $REPORT
+done

+ 21 - 0
tests/benchmarks/polybench/README.md

@@ -0,0 +1,21 @@
+# Introduction
+
+[PolyBench](https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1) is a benchmark suite of 30 numerical computations with static control flow, extracted from operations in various application domains (linear algebra computations, image processing, physics simulation, dynamic programming, statistics, etc.).
+
+**Source**: https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1
+
+# Building
+
+Please build iwasm and wamrc, refer to:
+- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos)
+- [build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler)
+
+And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`.
+
+And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it.
+
+# Running
+
+Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated.
+
+Run `./run_interp.sh` to test the benchmark, the native mode and iwasm interpreter mode will be tested for each workload, and the file `report.txt` will be generated.

+ 47 - 0
tests/benchmarks/polybench/build.sh

@@ -0,0 +1,47 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+OUT_DIR=$PWD/out
+WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
+POLYBENCH_CASES="datamining linear-algebra medley stencils"
+
+if [ ! -d PolyBenchC-4.2.1 ]; then
+    git clone https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1.git
+fi
+
+mkdir -p ${OUT_DIR}
+
+cd PolyBenchC-4.2.1
+
+for case in $POLYBENCH_CASES
+do
+    files=`find ${case} -name "*.c"`
+    for file in ${files}
+    do
+        file_name=${file##*/}
+        if [[ ${file_name} == "Nussinov.orig.c" ]]; then
+            continue
+        fi
+
+        echo "Build ${file_name%.*}_native"
+        gcc -O3 -I utilities -I ${file%/*} utilities/polybench.c ${file} \
+                -DPOLYBENCH_TIME -lm -o ${OUT_DIR}/${file_name%.*}_native
+
+        echo "Build ${file_name%.*}.wasm"
+        /opt/wasi-sdk/bin/clang -O3 -I utilities -I ${file%/*}      \
+                utilities/polybench.c ${file}                       \
+                -Wl,--export=__heap_base -Wl,--export=__data_end    \
+                -Wl,--export=malloc -Wl,--export=free               \
+                -DPOLYBENCH_TIME -o ${OUT_DIR}/${file_name%.*}.wasm
+
+        echo "Compile ${file_name%.*}.wasm into ${file_name%.*}.aot"
+        ${WAMRC_CMD} -o ${OUT_DIR}/${file_name%.*}.aot \
+                ${OUT_DIR}/${file_name%.*}.wasm
+    done
+done
+
+cd ..
+
+echo "Done"

+ 55 - 0
tests/benchmarks/polybench/run_aot.sh

@@ -0,0 +1,55 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+CUR_DIR=$PWD
+OUT_DIR=$CUR_DIR/out
+REPORT=$CUR_DIR/report.txt
+TIME=/usr/bin/time
+
+PLATFORM=$(uname -s | tr A-Z a-z)
+IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
+
+BENCH_NAME_MAX_LEN=20
+
+POLYBENCH_CASES="2mm 3mm adi atax bicg cholesky correlation covariance \
+                 deriche doitgen durbin fdtd-2d floyd-warshall gemm gemver \
+                 gesummv gramschmidt heat-3d jacobi-1d jacobi-2d ludcmp lu \
+                 mvt nussinov seidel-2d symm syr2k syrk trisolv trmm"
+
+rm -f $REPORT
+touch $REPORT
+
+function print_bench_name()
+{
+    name=$1
+    echo -en "$name" >> $REPORT
+    name_len=${#name}
+    if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
+    then
+        spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
+        for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
+    fi
+}
+
+echo "Start to run cases, the result is written to report.txt"
+
+#run benchmarks
+cd $OUT_DIR
+echo -en "\t\t\t\t\t  native\tiwasm-aot\n" >> $REPORT
+
+for t in $POLYBENCH_CASES
+do
+    print_bench_name $t
+
+    echo "run $t with native .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo "run $t with iwasm aot .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo -en "\n" >> $REPORT
+done

+ 55 - 0
tests/benchmarks/polybench/run_interp.sh

@@ -0,0 +1,55 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+CUR_DIR=$PWD
+OUT_DIR=$CUR_DIR/out
+REPORT=$CUR_DIR/report.txt
+TIME=/usr/bin/time
+
+PLATFORM=$(uname -s | tr A-Z a-z)
+IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
+
+BENCH_NAME_MAX_LEN=20
+
+POLYBENCH_CASES="2mm 3mm adi atax bicg cholesky correlation covariance \
+                 deriche doitgen durbin fdtd-2d floyd-warshall gemm gemver \
+                 gesummv gramschmidt heat-3d jacobi-1d jacobi-2d ludcmp lu \
+                 mvt nussinov seidel-2d symm syr2k syrk trisolv trmm"
+
+rm -f $REPORT
+touch $REPORT
+
+function print_bench_name()
+{
+    name=$1
+    echo -en "$name" >> $REPORT
+    name_len=${#name}
+    if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
+    then
+        spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
+        for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
+    fi
+}
+
+echo "Start to run cases, the result is written to report.txt"
+
+#run benchmarks
+cd $OUT_DIR
+echo -en "\t\t\t\t\t  native\tiwasm-aot\n" >> $REPORT
+
+for t in $POLYBENCH_CASES
+do
+    print_bench_name $t
+
+    echo "run $t with native .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo "run $t with iwasm interp .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" $IWASM_CMD ${t}.wasm 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo -en "\n" >> $REPORT
+done

+ 21 - 0
tests/benchmarks/sightglass/README.md

@@ -0,0 +1,21 @@
+# Introduction
+
+[Sightglass](https://github.com/bytecodealliance/sightglass) is a benchmarking suite and tooling to test WebAssembly applications.
+
+**Source**: https://github.com/bytecodealliance/sightglass
+
+# Building
+
+Please build iwasm and wamrc, refer to:
+- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos)
+- [build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler)
+
+And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`.
+
+And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it.
+
+# Running
+
+Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated.
+
+Run `./run_interp.sh` to test the benchmark, the native mode and iwasm interpreter mode will be tested for each workload, and the file `report.txt` will be generated.

+ 44 - 0
tests/benchmarks/sightglass/build.sh

@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+OUT_DIR=$PWD/out
+WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
+SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \
+                nestedloop2 nestedloop3 random seqhash sieve strchr \
+                switch2"
+
+if [ ! -d sightglass ]; then
+    git clone https://github.com/wasm-micro-runtime/sightglass.git
+fi
+
+mkdir -p ${OUT_DIR}
+
+cd sightglass/benchmarks/shootout
+
+for bench in $SHOOTOUT_CASES
+do
+    echo "Build ${bench}_native"
+    gcc -O3 -o ${OUT_DIR}/${bench}_native -Dblack_box=set_res -Dbench=${bench} \
+        -I../../include ${bench}.c main/main_${bench}.c main/my_libc.c
+
+    echo "Build ${bench}.wasm"
+    /opt/wasi-sdk/bin/clang -O3 -nostdlib \
+        -Wno-unknown-attributes \
+        -Dblack_box=set_res \
+        -I../../include -DNOSTDLIB_MODE \
+        -Wl,--initial-memory=1310720,--allow-undefined \
+        -Wl,--strip-all,--no-entry \
+        -o ${OUT_DIR}/${bench}.wasm \
+        -Wl,--export=app_main -Wl,--export=_start \
+        ${bench}.c main/main_${bench}.c main/my_libc.c
+
+
+    echo "Compile ${bench}.wasm into ${bench}.aot"
+    ${WAMRC_CMD} -o ${OUT_DIR}/${bench}.aot ${OUT_DIR}/${bench}.wasm
+done
+
+cd ..
+
+echo "Done"

+ 54 - 0
tests/benchmarks/sightglass/run_aot.sh

@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+CUR_DIR=$PWD
+OUT_DIR=$CUR_DIR/out
+REPORT=$CUR_DIR/report.txt
+TIME=/usr/bin/time
+
+PLATFORM=$(uname -s | tr A-Z a-z)
+IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
+
+BENCH_NAME_MAX_LEN=20
+
+SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \
+                nestedloop2 nestedloop3 random seqhash sieve strchr \
+                switch2"
+
+rm -f $REPORT
+touch $REPORT
+
+function print_bench_name()
+{
+    name=$1
+    echo -en "$name" >> $REPORT
+    name_len=${#name}
+    if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
+    then
+        spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
+        for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
+    fi
+}
+
+echo "Start to run cases, the result is written to report.txt"
+
+#run benchmarks
+cd $OUT_DIR
+echo -en "\t\t\t\t\t  native\tiwasm-aot\n" >> $REPORT
+
+for t in $SHOOTOUT_CASES
+do
+    print_bench_name $t
+
+    echo "run $t with native .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo "run $t with iwasm aot .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo -en "\n" >> $REPORT
+done

+ 54 - 0
tests/benchmarks/sightglass/run_interp.sh

@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+CUR_DIR=$PWD
+OUT_DIR=$CUR_DIR/out
+REPORT=$CUR_DIR/report.txt
+TIME=/usr/bin/time
+
+PLATFORM=$(uname -s | tr A-Z a-z)
+IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
+
+BENCH_NAME_MAX_LEN=20
+
+SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \
+                nestedloop2 nestedloop3 random seqhash sieve strchr \
+                switch2"
+
+rm -f $REPORT
+touch $REPORT
+
+function print_bench_name()
+{
+    name=$1
+    echo -en "$name" >> $REPORT
+    name_len=${#name}
+    if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
+    then
+        spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
+        for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
+    fi
+}
+
+echo "Start to run cases, the result is written to report.txt"
+
+#run benchmarks
+cd $OUT_DIR
+echo -en "\t\t\t\t\t  native\tiwasm-interp\n" >> $REPORT
+
+for t in $SHOOTOUT_CASES
+do
+    print_bench_name $t
+
+    echo "run $t with native .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo "run $t with iwasm aot .."
+    echo -en "\t" >> $REPORT
+    $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
+
+    echo -en "\n" >> $REPORT
+done