From cea1235cdffa7c8cc90c287a0d3aba8931a18800 Mon Sep 17 00:00:00 2001 From: Laszlo Voros Date: Mon, 13 May 2024 16:40:14 +0200 Subject: [PATCH] Benchmarker O2, fix CSV --- test/wasmBenchmarker/benchmark.py | 65 +++++--- test/wasmBenchmarker/ctests/change.c | 2 +- test/wasmBenchmarker/ctests/factorial.c | 12 +- test/wasmBenchmarker/ctests/fannkuch.c | 2 +- test/wasmBenchmarker/ctests/fibonacci.c | 8 +- test/wasmBenchmarker/ctests/gregory.c | 2 +- test/wasmBenchmarker/ctests/hanoi.c | 8 +- test/wasmBenchmarker/ctests/heapsort.c | 2 +- test/wasmBenchmarker/ctests/huffman.c | 2 +- .../ctests/include/mandelbrot.h | 4 +- .../ctests/include/simdMandelbrot.h | 4 +- test/wasmBenchmarker/ctests/kNucleotide.c | 30 +++- test/wasmBenchmarker/ctests/matrixMultiply.c | 4 +- test/wasmBenchmarker/ctests/nbody.c | 2 +- test/wasmBenchmarker/ctests/nqueens.c | 65 ++++---- test/wasmBenchmarker/ctests/prime.c | 2 +- test/wasmBenchmarker/ctests/quickSort.c | 2 +- test/wasmBenchmarker/ctests/redBlack.c | 3 +- test/wasmBenchmarker/ctests/rsa.c | 140 ++++++++++++++++-- test/wasmBenchmarker/ctests/salesman.c | 49 +++--- .../ctests/simdMatrixMultiply.c | 2 +- test/wasmBenchmarker/ctests/simdNbody.c | 2 +- test/wasmBenchmarker/ctests/ticTacToe.c | 2 +- 23 files changed, 287 insertions(+), 127 deletions(-) diff --git a/test/wasmBenchmarker/benchmark.py b/test/wasmBenchmarker/benchmark.py index e71197f10..22f312a67 100755 --- a/test/wasmBenchmarker/benchmark.py +++ b/test/wasmBenchmarker/benchmark.py @@ -21,6 +21,7 @@ import sys import time +from pathlib import Path from os.path import abspath, dirname, join from markdownTable import markdownTable # pip install py-markdown-table @@ -30,31 +31,31 @@ DIFF_TRESHOLD = 1e-7 expectedValues = { - "change": 4, - "factorial": 30, - "fannkuch": 120, - "fibonacci": 1, + "change": 3, + "factorial": 899999994000000000, + "fannkuch": 360, + "fibonacci": 63245986, "gregory": 3.14159264, - "hanoi": 0, + "hanoi": 67108863, "heapsort": 0, "huffman": 0, "kNucleotide": 1, - "mandelbrotFloat": 775007, - "mandelbrotDouble": 775007, + "mandelbrotFloat": 775014, + "mandelbrotDouble": 775014, "matrixMultiply": 3920.0, "miniWalrus": 27449, - "nbody": -0.16910574, - "nqueens": 0, - "prime": 48611, + "nbody": -0.16904405, + "nqueens": 246, + "prime": 70657, "quickSort": 0, - "redBlack": 4000000, + "redBlack": 13354000, "rsa": 0, - "salesman": 840, - "simdMandelbrotFloat": 775007, - "simdMandelbrotDouble": 775007, - "simdNbody": -0.16910574, + "salesman": 2520, + "simdMandelbrotFloat": 775014, + "simdMandelbrotDouble": 775014, + "simdNbody": -0.16904405, "simdMatrixMultiply": 3920.0, - "ticTacToe": 4748900 + "ticTacToe": 18995600 } # https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/simple.html#simple @@ -79,6 +80,7 @@ def parse_args(): parser.add_argument("--mem", help="measure MAX RSS", action="store_true") parser.add_argument("--jit", help="use JIT version of Walrus", action="store_true") parser.add_argument("--verbose", help="prints extra informations e.g. paths", action="store_true") + parser.add_argument("--no-system-emcc", help="Don't use emcc command from the system", action="store_true", default=False) return parser.parse_args() @@ -94,8 +96,14 @@ def check_programs(engines, verbose): if (verbose): print("Checks done") -def get_emcc(verbose): +def get_emcc(verbose, system_emcc=True): emcc_path = None + + if system_emcc and os.system("emcc --version >/dev/null") == 0: + if (verbose): print("Emscripten already installed on system") + emcc_path = "emcc" + return emcc_path + if os.getenv("EMSDK"): emcc_path = join(os.getenv("EMSDK"), "upstream/emscripten/emcc.py") if os.path.exists(emcc_path): @@ -105,12 +113,11 @@ def get_emcc(verbose): if os.path.exists("./emsdk/.git"): os.system("(cd ./emsdk && git fetch -a) >/dev/null") os.system("(cd ./emsdk && git reset --hard origin/HEAD) >/dev/null") - os.system("./emsdk/emsdk install latest >/dev/null") - os.system("./emsdk/emsdk activate latest >/dev/null") else: os.system("git clone --depth 1 https://github.com/emscripten-core/emsdk.git ./emsdk >/dev/null") - os.system("./emsdk/emsdk install latest >/dev/null") - os.system("./emsdk/emsdk activate latest >/dev/null") + + os.system("./emsdk/emsdk install latest >/dev/null") + os.system("./emsdk/emsdk activate latest >/dev/null") emcc_path = "./emsdk/upstream/emscripten/emcc" if (verbose): print(f"EMCC install done: {emcc_path}") @@ -118,7 +125,7 @@ def get_emcc(verbose): def compile_tests(emcc_path, path, only_game, only_simd, compile_anyway, run, verbose): - if not os.path.exists(emcc_path): + if os.system(f"{emcc_path} --version >/dev/null") != 0: raise Exception(f"Invalid path for emcc: {emcc_path}") if not os.path.exists(path): @@ -149,6 +156,7 @@ def compile_tests(emcc_path, path, only_game, only_simd, compile_anyway, run, ve flags = "-msimd128" if file.startswith("simd") else "" flags += (" -s WASM=1 -s EXPORTED_FUNCTIONS=_runtime" " -s EXPORTED_RUNTIME_METHODS=ccall,cwrap" + " -O2" f" -o {path}/wasm/{name}.wasm") if (verbose): print(f"compiling {name}") command = f"{emcc_path} {path}/{file} {flags}" @@ -242,11 +250,14 @@ def generate_report(data, file_name=None): engine_names.remove("test") for engineName in engine_names: header += f";{engineName}" + header += "\n" file.write(header) for record in data: line = record["test"] for engineName in engine_names: line += f";{record[engineName]}" + + line += "\n" file.write(line) return file.write(markdownTable(data).setParams(row_sep="markdown", quote=False).getMarkdown()) @@ -260,14 +271,20 @@ def main(): print("You need to specify the engine locations", file=sys.stderr) exit(1) + memreport = None + if args.report is not None: + memreport = Path(args.report).absolute() + memreport = memreport.parent / f"{memreport.stem}_mem{memreport.suffix}" + memreport = str(memreport) + check_programs(args.engines, args.verbose) - emcc_path = get_emcc(args.verbose) + emcc_path = get_emcc(args.verbose, not args.no_system_emcc) test_names = compile_tests(emcc_path, args.test_dir, args.only_game, args.only_simd, args.compile_anyway, args.run, args.verbose) result_data = run_tests(args.test_dir, test_names, args.engines, args.iterations, args.mem, args.jit, args.verbose) generate_report(result_data["time"], args.report) if (args.mem): - generate_report(result_data["mem"], args.report) + generate_report(result_data["mem"], memreport) if __name__ == "__main__": diff --git a/test/wasmBenchmarker/ctests/change.c b/test/wasmBenchmarker/ctests/change.c index 6fcb18d5a..867f2ce2e 100755 --- a/test/wasmBenchmarker/ctests/change.c +++ b/test/wasmBenchmarker/ctests/change.c @@ -20,7 +20,7 @@ uint32_t coins[] = {5, 10, 20, 50, 100, 200}; #define COINT_NUMBER sizeof(coins) / sizeof(uint32_t) -#define MONEY 85 +#define MONEY 155 /* * Return the smallest number of coins diff --git a/test/wasmBenchmarker/ctests/factorial.c b/test/wasmBenchmarker/ctests/factorial.c index 66dbd46a9..7dcee0d17 100755 --- a/test/wasmBenchmarker/ctests/factorial.c +++ b/test/wasmBenchmarker/ctests/factorial.c @@ -17,9 +17,9 @@ #include #include -uint64_t factorial(uint8_t n) { - uint8_t counter = 0; - for (uint8_t i = 0; i < n; i++, counter++) { +uint64_t factorial(uint64_t n) { + uint64_t counter = 0; + for (uint64_t i = 0; i < n; i++, counter++) { factorial(n - 1); } @@ -29,8 +29,10 @@ uint64_t factorial(uint8_t n) { uint64_t runtime() { uint64_t retVal = 0; - for (uint16_t i = 0; i < 3; i++) { - retVal += factorial(10); + for (uint64_t i = 0; i < 6000000000; i++) { + retVal += factorial(150000000); + retVal -= factorial(149999999); + retVal += factorial(149999998); } return retVal; diff --git a/test/wasmBenchmarker/ctests/fannkuch.c b/test/wasmBenchmarker/ctests/fannkuch.c index 047c3c874..3d713a15d 100755 --- a/test/wasmBenchmarker/ctests/fannkuch.c +++ b/test/wasmBenchmarker/ctests/fannkuch.c @@ -78,7 +78,7 @@ uint64_t fannkuch(uint64_t n) { uint64_t runtime() { uint64_t retVal = 0; - for (uint8_t i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 12; i++) { retVal += fannkuch(9); } diff --git a/test/wasmBenchmarker/ctests/fibonacci.c b/test/wasmBenchmarker/ctests/fibonacci.c index 9a2f2ba78..c3e4b48b2 100755 --- a/test/wasmBenchmarker/ctests/fibonacci.c +++ b/test/wasmBenchmarker/ctests/fibonacci.c @@ -19,17 +19,15 @@ uint64_t fibonacci(uint64_t n) { if (n == 0 || n == 1) { - return 1; + return n; } - fibonacci(n - 1); - fibonacci(n - 2); - return fibonacci(n - 2); + return fibonacci(n - 1) + fibonacci(n - 2); } uint64_t runtime() { - return fibonacci(26); + return fibonacci(39); } int main() { diff --git a/test/wasmBenchmarker/ctests/gregory.c b/test/wasmBenchmarker/ctests/gregory.c index 12be678cc..7e280d361 100755 --- a/test/wasmBenchmarker/ctests/gregory.c +++ b/test/wasmBenchmarker/ctests/gregory.c @@ -28,7 +28,7 @@ double gregorySeries(uint64_t n) { } double runtime() { - return gregorySeries(75000000); + return gregorySeries(300000000); } int main() { diff --git a/test/wasmBenchmarker/ctests/hanoi.c b/test/wasmBenchmarker/ctests/hanoi.c index f45148998..53b75ce4a 100755 --- a/test/wasmBenchmarker/ctests/hanoi.c +++ b/test/wasmBenchmarker/ctests/hanoi.c @@ -20,19 +20,21 @@ #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 -#define DISKS 24 +#define DISKS 26 typedef struct { uint64_t disks[DISKS]; uint64_t size; // current size } rod; +uint32_t steps = 0; void move_disk(rod *from, rod *to) { if (from->size == 0) { return; } if (to->size == 0) { + steps++; to->disks[0] = from->disks[from->size - 1]; from->size -= 1; to->size += 1; @@ -41,6 +43,7 @@ void move_disk(rod *from, if (from->disks[from->size - 1] < to->disks[to->size - 1]) { return; } + steps++; to->disks[to->size] = from->disks[from->size - 1]; from->size -= 1; to->size += 1; @@ -64,6 +67,7 @@ void move_tower(rod *from, uint64_t hanoi() { // init + steps = 0; rod rods[3]; for (int i = 0; i < DISKS; i++) { rods[0].disks[i] = i; @@ -86,7 +90,7 @@ uint64_t hanoi() { return EXIT_FAILURE; } } - return EXIT_SUCCESS; + return steps; } uint64_t runtime() { diff --git a/test/wasmBenchmarker/ctests/heapsort.c b/test/wasmBenchmarker/ctests/heapsort.c index 1ce579afc..fa92e1431 100755 --- a/test/wasmBenchmarker/ctests/heapsort.c +++ b/test/wasmBenchmarker/ctests/heapsort.c @@ -19,7 +19,7 @@ #include "include/random.h" #define ARRAY_LENGTH 15000 -#define ITERATIONS 64 +#define ITERATIONS 300 #define NO_CHILD 0 #define NO_PARENT 65535 diff --git a/test/wasmBenchmarker/ctests/huffman.c b/test/wasmBenchmarker/ctests/huffman.c index ac32f14ab..5e4ee348a 100755 --- a/test/wasmBenchmarker/ctests/huffman.c +++ b/test/wasmBenchmarker/ctests/huffman.c @@ -29,7 +29,7 @@ byte runtime(); // TEST PARAMETER -#define ITERATIONS 3 +#define ITERATIONS 7 char* message = "Lorem ipsum dolor sit amet, et wisi primis duo." "In quo erat tritani fuisset, no ullum vivendo " diff --git a/test/wasmBenchmarker/ctests/include/mandelbrot.h b/test/wasmBenchmarker/ctests/include/mandelbrot.h index b82e1a1dc..72d91502c 100644 --- a/test/wasmBenchmarker/ctests/include/mandelbrot.h +++ b/test/wasmBenchmarker/ctests/include/mandelbrot.h @@ -34,8 +34,8 @@ #include #include -#define WIDTH 1600 -#define HIGHT 1400 +#define WIDTH 12800 +#define HIGHT 11200 #define N 20 #define REAL_AXIS_SHIFT -1.8 // ~ horizontal shift #define IMAGINARY_AXIS_SHIFT -1.0 // ~ vertical shift diff --git a/test/wasmBenchmarker/ctests/include/simdMandelbrot.h b/test/wasmBenchmarker/ctests/include/simdMandelbrot.h index d6c92eadf..021795b67 100644 --- a/test/wasmBenchmarker/ctests/include/simdMandelbrot.h +++ b/test/wasmBenchmarker/ctests/include/simdMandelbrot.h @@ -35,8 +35,8 @@ #include -#define WIDTH 1600 -#define HIGHT 1400 +#define WIDTH 6400 +#define HIGHT 5600 #define N 20 #define REAL_AXIS_SHIFT -1.8 // ~ horizontal shift #define IMAGINARY_AXIS_SHIFT -1.0 // ~ vertical shift diff --git a/test/wasmBenchmarker/ctests/kNucleotide.c b/test/wasmBenchmarker/ctests/kNucleotide.c index cf2f61f14..1919fe88b 100755 --- a/test/wasmBenchmarker/ctests/kNucleotide.c +++ b/test/wasmBenchmarker/ctests/kNucleotide.c @@ -18,6 +18,8 @@ #include #include +#define LOOP 2 + extern const char *input_3; typedef struct { @@ -221,14 +223,26 @@ bool check() { } bool runtime() { - frequency(input_3, 1); - frequency(input_3, 2); - count(input_3, "ggt"); - count(input_3, "ggta"); - count(input_3, "ggtatt"); - count(input_3, "ggtattttaatt"); - count(input_3, "ggtattttaatttatagt"); - return check(); + uint8_t checks = 0; + for(uint8_t i = 0; i < LOOP; i++) { + for(uint8_t j = 0; j < record_current_size; j++) { + for (uint8_t k = 0; k < 50; k++) { + records[j].key[k] = 0; + } + records[j].value=0; + } + frequency(input_3, 1); + frequency(input_3, 2); + count(input_3, "ggt"); + count(input_3, "ggta"); + count(input_3, "ggtatt"); + count(input_3, "ggtattttaatt"); + count(input_3, "ggtattttaatttatagt"); + if (check()) { + checks += 1; + } + } + return checks == LOOP; } const char *input_3 = diff --git a/test/wasmBenchmarker/ctests/matrixMultiply.c b/test/wasmBenchmarker/ctests/matrixMultiply.c index 7b9f3fea0..c2dd63375 100644 --- a/test/wasmBenchmarker/ctests/matrixMultiply.c +++ b/test/wasmBenchmarker/ctests/matrixMultiply.c @@ -18,8 +18,8 @@ #include #include -// 4x4 square matrix -#define MATRIX_SIZE 16 +// 13x13 square matrix +#define MATRIX_SIZE 169 #define ITERATION 3500000 diff --git a/test/wasmBenchmarker/ctests/nbody.c b/test/wasmBenchmarker/ctests/nbody.c index 211927782..03345a941 100755 --- a/test/wasmBenchmarker/ctests/nbody.c +++ b/test/wasmBenchmarker/ctests/nbody.c @@ -17,7 +17,7 @@ #include #include -#define LOOP 450000 +#define LOOP 3000000 #define SOLAR_MASS 39.47841760435743f #define DAYS_PER_YEAR 365.24f #define BODIES_COUNT 5 diff --git a/test/wasmBenchmarker/ctests/nqueens.c b/test/wasmBenchmarker/ctests/nqueens.c index 68ba012e7..c6b0ca6b3 100755 --- a/test/wasmBenchmarker/ctests/nqueens.c +++ b/test/wasmBenchmarker/ctests/nqueens.c @@ -21,10 +21,12 @@ // This test generates a solution to the N Queens problem, a variation of 8 Queens problem. // Description of problem: https://en.wikipedia.org/wiki/Eight_queens_puzzle -#define N 18 +#define N 25 +#define LOOP 3 uint8_t board[N][N]; -void print_board(uint8_t board[N][N]) { +void print_board(uint8_t board[N][N]) +{ for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { printf("%d", board[i][j]); @@ -32,7 +34,8 @@ void print_board(uint8_t board[N][N]) { } } -bool is_safe(uint8_t board[N][N], unsigned row, unsigned col) { +bool is_safe(uint8_t board[N][N], unsigned row, unsigned col) +{ for (int i = 0; i < N; ++i) { if (board[row][i] == 1) return false; @@ -66,7 +69,8 @@ bool is_safe(uint8_t board[N][N], unsigned row, unsigned col) { return true; } -bool nqueens(uint8_t board[N][N], int32_t col) { +bool nqueens(uint8_t board[N][N], int32_t col) +{ if (col >= N) { return true; } @@ -84,42 +88,45 @@ bool nqueens(uint8_t board[N][N], int32_t col) { return false; } -uint8_t runtime() { +uint8_t runtime() +{ uint8_t retVal = 5; - - for (uint8_t c = 0; c < 5; c++) { - int32_t start_col = 0; - for (int i = 0; i < N; i++) { - for (int j = 0; j < N; j++) { - board[i][j] = 0; + for (uint8_t l = 0; l < LOOP; l++) { + for (uint8_t c = 0; c < 5; c++) { + int32_t start_col = 0; + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + board[i][j] = 0; + } } - } - bool wasBreak = false; + bool wasBreak = false; + + while (true) { + if (nqueens(board, start_col)) { + retVal--; + wasBreak = true; + break; + } else if (start_col < N) { + start_col++; + } else { + retVal++; + wasBreak = true; + break; + } + } - while (true) { - if (nqueens(board, start_col)) { - retVal--; - wasBreak = true; - break; - } else if (start_col < N) { - start_col++; - } else { + if (!wasBreak) { retVal++; - wasBreak = true; - break; } } - - if (!wasBreak) { - retVal++; - } } return retVal; } -int main() { +int main() +{ printf("%u\n", runtime()); return 0; -} \ No newline at end of file +} diff --git a/test/wasmBenchmarker/ctests/prime.c b/test/wasmBenchmarker/ctests/prime.c index 18ca6fe75..e0967f4f4 100755 --- a/test/wasmBenchmarker/ctests/prime.c +++ b/test/wasmBenchmarker/ctests/prime.c @@ -21,7 +21,7 @@ #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 -#define PRIME_NUMBER 5000 +#define PRIME_NUMBER 7000 // return the greatest x, where x^2 <= number diff --git a/test/wasmBenchmarker/ctests/quickSort.c b/test/wasmBenchmarker/ctests/quickSort.c index 7bc7a7fb4..3d859d4f7 100755 --- a/test/wasmBenchmarker/ctests/quickSort.c +++ b/test/wasmBenchmarker/ctests/quickSort.c @@ -22,7 +22,7 @@ // TEST PARAMETERS #define SIZE 500 // size of array to be ordered -#define ITERATIONS 6 +#define ITERATIONS 17 /** * Order the given array with the quicksort diff --git a/test/wasmBenchmarker/ctests/redBlack.c b/test/wasmBenchmarker/ctests/redBlack.c index e7fb38300..91be486f1 100755 --- a/test/wasmBenchmarker/ctests/redBlack.c +++ b/test/wasmBenchmarker/ctests/redBlack.c @@ -17,7 +17,7 @@ #include #include -#define RBSIZE 1000 +#define RBSIZE 1669 #define RED 0 #define BLACK 1 @@ -429,6 +429,7 @@ uint64_t runtime() { for (uint32_t i = 0; i < 1000; i++) { retVal += runRedBlack(); + retVal += runRedBlack(); } return retVal; diff --git a/test/wasmBenchmarker/ctests/rsa.c b/test/wasmBenchmarker/ctests/rsa.c index 0007476fc..676ae026d 100644 --- a/test/wasmBenchmarker/ctests/rsa.c +++ b/test/wasmBenchmarker/ctests/rsa.c @@ -228,22 +228,134 @@ int runtime() { "te eum quod blandit. Vim ad legimus intellegebat " "disputationi, an ridens nonumes deterruisset sed. Eos " "dicunt assentior eu, mel ne case postulant, " - "quando feugiat voluptaria eam ne.\n"; + "quando feugiat voluptaria eam ne.\n" + "Curabitur vitae erat tortor. Lorem ipsum dolor " + "sit amet, consectetur adipiscing elit. Integer " + "ut ligula nec odio bibendum tempus. Suspendisse" + " id neque nec tortor faucibus congue. Donec vit" + "ae tortor at tellus feugiat dictum eget non sem" + ". Mauris malesuada tellus commodo, congue massa" + " sed, tristique nunc. Duis facilisis risus nec " + "eros rutrum scelerisque ac sit amet nibh. Integ" + "er urna ipsum, vestibulum a dui et, varius vene" + "natis lectus.\n\nInteger purus arcu, fermentum " + "sit amet ultricies in, consequat non urna. Maur" + "is convallis risus ut nulla porta, vitae posuer" + "e sapien commodo. Mauris pulvinar ligula a pulv" + "inar auctor. Fusce at cursus lectus, sit amet s" + "celerisque dolor. Quisque lacinia mauris vestib" + "ulum lacus rutrum vestibulum. Nullam ut ex elem" + "entum, suscipit leo in, egestas purus. Vestibul" + "um ligula velit, rutrum eget dapibus et, tempor" + " ut arcu. Nunc mattis ante ante, ut interdum ma" + "ssa congue at. Proin tortor eros, euismod sit a" + "met justo eu, tincidunt viverra nunc. Morbi sit" + " amet venenatis sapien. In sollicitudin urna en" + "im, eget porttitor diam pulvinar ut. Pellentesq" + "ue placerat euismod mattis. Cras sit amet leo e" + "t purus facilisis dictum eget quis libero.\n\nP" + "raesent ipsum dui, luctus vitae neque vitae, lo" + "bortis egestas nunc. Proin id leo sed urna ulla" + "mcorper vehicula ullamcorper quis purus. Mauris" + " nec cursus nibh, quis posuere ligula. Nullam r" + "honcus lacus non risus dictum luctus. Praesent " + "nulla orci, ultrices commodo tincidunt et, aliq" + "uam ac mauris. In laoreet convallis feugiat. Et" + "iam quis eros vitae enim porttitor cursus in vo" + "lutpat turpis. Quisque tempor turpis leo. Duis " + "at diam ac odio rutrum eleifend.\n\nEtiam id po" + "rta lacus. Sed pellentesque eleifend tellus, tr" + "istique mollis dui congue nec. Phasellus ante e" + "st, mollis semper libero suscipit, vestibulum v" + "ehicula diam. Phasellus pretium ex ut diam aliq" + "uam, quis venenatis sapien maximus. Morbi eget " + "interdum felis, sed aliquam magna. Pellentesque" + " fermentum est sapien, at congue mauris convall" + "is eu. Aliquam mattis aliquet libero id blandit" + ". Maecenas turpis augue, pretium eget finibus i" + "n, cursus quis ligula. Pellentesque habitant mo" + "rbi tristique senectus et netus et malesuada fa" + "mes ac turpis egestas.\n\nVestibulum pharetra t" + "ortor non nibh scelerisque congue. Morbi fermen" + "tum, enim at accumsan luctus, tellus ante moles" + "tie est, ut aliquet ipsum nulla quis sem. Aliqu" + "am eget ligula ut diam accumsan semper ultricie" + "s eget ante. Donec aliquet odio sed nibh euismo" + "d, sed efficitur nulla condimentum. Aliquam ult" + "rices, ipsum vitae pretium vulputate, libero ju" + "sto dictum velit, eu placerat purus leo quis fe" + "lis. Praesent ultrices massa nulla, at porta ma" + "ssa vehicula vel. Morbi vulputate nulla eget ur" + "na ornare, sed posuere est imperdiet. In non mi" + " vel libero pellentesque condimentum id sed mi." + " Praesent id nibh massa. Donec porttitor effici" + "tur enim, eget ultrices mi commodo at. Proin he" + "ndrerit justo eu fermentum ornare. Vivamus pulv" + "inar ex quis nisi fringilla imperdiet. Vivamus " + "efficitur lectus sit amet ipsum scelerisque rut" + "rum.\n\nDuis ac justo tellus. Aliquam erat volu" + "tpat. Duis sed nisl massa. Fusce posuere, magna" + " eget posuere tincidunt, lorem nisi tristique a" + "nte, in egestas enim ipsum ut sem. Phasellus si" + "t amet gravida elit. Nulla aliquam lectus condi" + "mentum ex rhoncus varius. Praesent facilisis du" + "i eget vestibulum placerat. Suspendisse et cons" + "ectetur enim, vitae imperdiet ante. Praesent ne" + "c tortor placerat, aliquet ex iaculis, semper f" + "elis. Duis gravida libero quis neque condimentu" + "m volutpat. Class aptent taciti sociosqu ad lit" + "ora torquent per conubia nostra, per inceptos h" + "imenaeos.\n\nInteger et purus pulvinar, finibus" + " quam at, sodales ipsum. Maecenas eu elementum " + "dui. Sed condimentum ullamcorper nisi, a lacini" + "a ante sagittis sit amet. Aliquam sed tempus au" + "gue. Donec condimentum placerat metus id posuer" + "e. Sed placerat blandit lorem, vitae pulvinar e" + "ros fermentum quis. Nunc sed mi in ipsum suscip" + "it iaculis in at mi. In sed lorem eu purus cong" + "ue maximus. Cras gravida, elit et sagittis phar" + "etra, elit mi volutpat augue, a volutpat leo lo" + "rem luctus eros. Pellentesque maximus lorem eu " + "bibendum suscipit. Nullam ipsum massa, eleifend" + " quis faucibus in, fermentum non lorem. Sed vol" + "utpat facilisis felis, ut laoreet est venenatis" + " mollis.\n\nPhasellus efficitur ante et eros ul" + "trices aliquet. Morbi molestie neque ante, pell" + "entesque vulputate mauris dictum id. Donec eu d" + "apibus enim. Maecenas non lacus orci. Suspendis" + "se potenti. Donec at arcu ac nunc laoreet eleme" + "ntum id et ipsum. Suspendisse sed justo purus. " + "Donec malesuada, nibh ac facilisis congue, mass" + "a risus porttitor nulla, a mattis turpis augue " + "non augue. In varius sem et nunc auctor sollici" + "tudin. Praesent dapibus faucibus vulputate. Qui" + "sque quis ipsum lacus. Pellentesque et sapien d" + "ui. Proin ut lacus dapibus, convallis ligula ul" + "lamcorper, finibus sem. Vestibulum sapien neque" + ", facilisis nec lacus ut, venenatis maximus lig" + "ula.\n\nMorbi sit amet accumsan ante, eu ullamc" + "orper libero. Donec eu cursus tellus. Nunc susc" + "ipit augue odio, nec tincidunt tortor efficitur" + " non. Vivamus eget erat odio. Maecenas tincidun" + "t in nunc interdum pellentesque. Maecenas nec o" + "dio justo. Vivamus ultricies quam nisi, et vulp"; const int messageLength = sizeof(message) / sizeof(char); - const uint64_t prime1 = NthPrimeAfterNumber(350, 0); - const uint64_t prime2 = NthPrimeAfterNumber(1, prime1); - PublicKey publicKey; - PrivateKey privateKey; - generateKeys(prime1, prime2, &publicKey, &privateKey); - uint64_t encryptedMessage[messageLength]; - encryptMessage((uint8_t*)message, messageLength, publicKey, encryptedMessage); - char decryptedMessage[messageLength]; - decryptMessage(encryptedMessage, messageLength, privateKey, (uint8_t*)decryptedMessage); - if (areEqual(message, decryptedMessage)) { - return 0; - } else { - return 1; + + for(int i = 100; i < 650; i++) { + const uint64_t prime1 = NthPrimeAfterNumber(i, 0); + const uint64_t prime2 = NthPrimeAfterNumber(1, prime1); + PublicKey publicKey; + PrivateKey privateKey; + generateKeys(prime1, prime2, &publicKey, &privateKey); + uint64_t encryptedMessage[messageLength]; + encryptMessage((uint8_t*)message, messageLength, publicKey, encryptedMessage); + char decryptedMessage[messageLength]; + decryptMessage(encryptedMessage, messageLength, privateKey, (uint8_t*)decryptedMessage); + if (!areEqual(message, decryptedMessage)) { + return 1; + } } + return 0; } int main() { diff --git a/test/wasmBenchmarker/ctests/salesman.c b/test/wasmBenchmarker/ctests/salesman.c index 0142dd868..5047771f3 100755 --- a/test/wasmBenchmarker/ctests/salesman.c +++ b/test/wasmBenchmarker/ctests/salesman.c @@ -19,8 +19,10 @@ #include #define V 10 +#define LOOP 3 -uint8_t next_permutation(int *p, int len) { +uint8_t next_permutation(int *p, int len) +{ int found = 0; int i = len - 2; @@ -68,11 +70,13 @@ uint8_t next_permutation(int *p, int len) { return 1; } -int min(int a, int b) { +int min(int a, int b) +{ return a < b ? a : b; } -uint32_t shortest_path_sum(int edges_list[][V], int s) { +uint32_t shortest_path_sum(int edges_list[][V], int s) +{ int nodes[V * V]; int n = 0; @@ -101,29 +105,30 @@ uint32_t shortest_path_sum(int edges_list[][V], int s) { return shortest_path; } -uint32_t runtime() { - +uint32_t runtime() +{ uint32_t retVal = 0; - - for (uint8_t i = 0; i < 7; i++) { - int edges_list[V][V] = - {{0, 10, 15, 20, 25, 30, 35, 40, 45, 50}, - {10, 0, 35, 25, 20, 15, 20, 10, 5, 35}, - {15, 35, 0, 30, 10, 40, 50, 10, 10, 10}, - {20, 25, 30, 0, 35, 15, 10, 30, 20, 10}, - {25, 20, 10, 35, 0, 30, 15, 20, 25, 30}, - {30, 15, 40, 15, 30, 0, 20, 10, 15, 20}, - {35, 20, 50, 10, 15, 20, 0, 25, 30, 35}, - {40, 10, 10, 30, 20, 10, 25, 0, 35, 40}, - {45, 5, 10, 20, 25, 15, 30, 35, 0, 45}, - {50, 35, 10, 10, 30, 20, 35, 40, 45, 0}}; - - retVal += shortest_path_sum(edges_list, 0); + for (uint8_t l = 0; l < LOOP; l++) { + for (uint8_t i = 0; i < 7; i++) { + int edges_list[V][V] = { { 0, 10, 15, 20, 25, 30, 35, 40, 45, 50 }, + { 10, 0, 35, 25, 20, 15, 20, 10, 5, 35 }, + { 15, 35, 0, 30, 10, 40, 50, 10, 10, 10 }, + { 20, 25, 30, 0, 35, 15, 10, 30, 20, 10 }, + { 25, 20, 10, 35, 0, 30, 15, 20, 25, 30 }, + { 30, 15, 40, 15, 30, 0, 20, 10, 15, 20 }, + { 35, 20, 50, 10, 15, 20, 0, 25, 30, 35 }, + { 40, 10, 10, 30, 20, 10, 25, 0, 35, 40 }, + { 45, 5, 10, 20, 25, 15, 30, 35, 0, 45 }, + { 50, 35, 10, 10, 30, 20, 35, 40, 45, 0 } }; + + retVal += shortest_path_sum(edges_list, 0); + } } return retVal; } -int main() { +int main() +{ printf("%u\n", runtime()); -} \ No newline at end of file +} diff --git a/test/wasmBenchmarker/ctests/simdMatrixMultiply.c b/test/wasmBenchmarker/ctests/simdMatrixMultiply.c index aeffca4ab..6e2e8c35b 100644 --- a/test/wasmBenchmarker/ctests/simdMatrixMultiply.c +++ b/test/wasmBenchmarker/ctests/simdMatrixMultiply.c @@ -20,7 +20,7 @@ #include // 4x4 square matrix -#define MATRIX_SIZE 16 +#define MATRIX_SIZE 144 #define ITERATION 3500000 diff --git a/test/wasmBenchmarker/ctests/simdNbody.c b/test/wasmBenchmarker/ctests/simdNbody.c index 595ac1c0b..1c98ad7e9 100755 --- a/test/wasmBenchmarker/ctests/simdNbody.c +++ b/test/wasmBenchmarker/ctests/simdNbody.c @@ -19,7 +19,7 @@ #include -#define LOOP 450000 +#define LOOP 3000000 #define SOLAR_MASS 39.47841760435743f #define DAYS_PER_YEAR 365.24f #define BODIES_COUNT 5 diff --git a/test/wasmBenchmarker/ctests/ticTacToe.c b/test/wasmBenchmarker/ctests/ticTacToe.c index 66de9d110..de44be348 100644 --- a/test/wasmBenchmarker/ctests/ticTacToe.c +++ b/test/wasmBenchmarker/ctests/ticTacToe.c @@ -17,7 +17,7 @@ #include #include -#define ITERATION 50 +#define ITERATION 200 typedef enum { X,