diff --git a/runtime/src/main.c b/runtime/src/main.c index 2883205..2241d5f 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -20,6 +20,18 @@ u32 ncores = 0, sbox_ncores = 0, sbox_core_st = 0; pthread_t rtthd[SBOX_NCORES]; +static unsigned long long +get_time() +{ + struct timeval Tp; + int stat; + stat = gettimeofday (&Tp, NULL); + if (stat != 0) + printf ("Error return from gettimeofday: %d", stat); + return (Tp.tv_sec * 1000000 + Tp.tv_usec); +} + + static void usage(char *cmd) { @@ -141,7 +153,11 @@ main(int argc, char** argv) /* in current dir! */ struct module *m = module_alloc(args, args, ac, 0, 0, 0, 0, 0, 0); assert(m); + + //unsigned long long st = get_time(), en; struct sandbox *s = sandbox_alloc(m, args, 0, NULL); + //en = get_time(); + //fprintf(stderr, "%llu\n", en - st); exit(0); #endif diff --git a/runtime/tests/Makefile b/runtime/tests/Makefile index 36e2104..bcfa715 100644 --- a/runtime/tests/Makefile +++ b/runtime/tests/Makefile @@ -2,7 +2,7 @@ include Makefile.inc BENCH_DIR=../../silverfish/code_benches/ -TESTS=fibonacci empty work +TESTS=fibonacci empty work work1k work10k work100k work1m #TESTS=forever filesys sockserver sockclient empty TESTSRT=$(TESTS:%=%_rt) BENCHES=adpcm basic_math binarytrees bitcount blowfish crc dijkstra fft function_pointers \ diff --git a/runtime/tests/test_work100k.json b/runtime/tests/test_work100k.json new file mode 100644 index 0000000..a1d9d29 --- /dev/null +++ b/runtime/tests/test_work100k.json @@ -0,0 +1,13 @@ +{ + "active" : "yes", + "name" : "work100k", + "path" : "work100k_wasm.so", + "port" : 10000, + "argsize" : 1, + "http-req-headers" : [ ], + "http-req-content-type" : "text/plain", + "http-req-size": 102600, + "http-resp-headers" : [ ], + "http-resp-size" : 102600, + "http-resp-content-type" : "text/plain" +} diff --git a/runtime/tests/test_work10k.json b/runtime/tests/test_work10k.json new file mode 100644 index 0000000..fc0a0fd --- /dev/null +++ b/runtime/tests/test_work10k.json @@ -0,0 +1,13 @@ +{ + "active" : "yes", + "name" : "work10k", + "path" : "work10k_wasm.so", + "port" : 10000, + "argsize" : 1, + "http-req-headers" : [ ], + "http-req-content-type" : "text/plain", + "http-req-size": 10480, + "http-resp-headers" : [ ], + "http-resp-size" : 10480, + "http-resp-content-type" : "text/plain" +} diff --git a/runtime/tests/test_work1k.json b/runtime/tests/test_work1k.json new file mode 100644 index 0000000..c332049 --- /dev/null +++ b/runtime/tests/test_work1k.json @@ -0,0 +1,13 @@ +{ + "active" : "yes", + "name" : "work1k", + "path" : "work1k_wasm.so", + "port" : 10000, + "argsize" : 1, + "http-req-headers" : [ ], + "http-req-content-type" : "text/plain", + "http-req-size": 1200, + "http-resp-headers" : [ ], + "http-resp-size" : 1200, + "http-resp-content-type" : "text/plain" +} diff --git a/runtime/tests/test_work1m.json b/runtime/tests/test_work1m.json new file mode 100644 index 0000000..4cdffde --- /dev/null +++ b/runtime/tests/test_work1m.json @@ -0,0 +1,13 @@ +{ + "active" : "yes", + "name" : "work1m", + "path" : "work1m_wasm.so", + "port" : 10000, + "argsize" : 1, + "http-req-headers" : [ ], + "http-req-content-type" : "text/plain", + "http-req-size": 1048576, + "http-resp-headers" : [ ], + "http-resp-size" : 1048776, + "http-resp-content-type" : "text/plain" +} diff --git a/runtime/tests/work/main.c b/runtime/tests/work/main.c index 2694657..3ad7416 100644 --- a/runtime/tests/work/main.c +++ b/runtime/tests/work/main.c @@ -2,24 +2,9 @@ #include #include -#define CPU_CYCS 2100 +#ifndef MAX_BUF #define MAX_BUF (1024*1024*1) //1m - -#define ITERS_15US 125500 -#define MULTIPLE 5 - -#define SPIN_ITERS (ITERS_15US*MULTIPLE) - -__attribute__((optnone)) static void -wrk(void) -{ - unsigned int spin = 0; - - while (spin < SPIN_ITERS) { - //__asm__ __volatile__("nop": : :"memory"); - spin++; - } -} +#endif //__attribute__((optnone)) int int diff --git a/runtime/tests/work100k/main.c b/runtime/tests/work100k/main.c new file mode 100644 index 0000000..57a483f --- /dev/null +++ b/runtime/tests/work100k/main.c @@ -0,0 +1,24 @@ +#include +#include +#include + +#define MAX_BUF 102400 + +//__attribute__((optnone)) int +int +main(void) +{ + char *d = malloc(MAX_BUF + 1); + int r = read(0, d, MAX_BUF); + +// unsigned long long st = rdtsc(), en = 0; +// wrk(); +// en = rdtsc(); + +// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); + if (r < 0) printf("E\n"); + else if (r <= 1) printf("D\n"); + else write(1, d, r); + + return 0; +} diff --git a/runtime/tests/work10k/main.c b/runtime/tests/work10k/main.c new file mode 100644 index 0000000..d034c1e --- /dev/null +++ b/runtime/tests/work10k/main.c @@ -0,0 +1,24 @@ +#include +#include +#include + +#define MAX_BUF 10240 + +//__attribute__((optnone)) int +int +main(void) +{ + char *d = malloc(MAX_BUF + 1); + int r = read(0, d, MAX_BUF); + +// unsigned long long st = rdtsc(), en = 0; +// wrk(); +// en = rdtsc(); + +// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); + if (r < 0) printf("E\n"); + else if (r <= 1) printf("D\n"); + else write(1, d, r); + + return 0; +} diff --git a/runtime/tests/work1k/main.c b/runtime/tests/work1k/main.c new file mode 100644 index 0000000..eb44340 --- /dev/null +++ b/runtime/tests/work1k/main.c @@ -0,0 +1,24 @@ +#include +#include +#include + +#define MAX_BUF 1024 + +//__attribute__((optnone)) int +int +main(void) +{ + char *d = malloc(MAX_BUF + 1); + int r = read(0, d, MAX_BUF); + +// unsigned long long st = rdtsc(), en = 0; +// wrk(); +// en = rdtsc(); + +// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); + if (r < 0) printf("E\n"); + else if (r <= 1) printf("D\n"); + else write(1, d, r); + + return 0; +} diff --git a/runtime/tests/work1m/main.c b/runtime/tests/work1m/main.c new file mode 100644 index 0000000..b7f2273 --- /dev/null +++ b/runtime/tests/work1m/main.c @@ -0,0 +1,24 @@ +#include +#include +#include + +#define MAX_BUF (1024*1024*1) //1m + +//__attribute__((optnone)) int +int +main(void) +{ + char *d = malloc(MAX_BUF + 1); + int r = read(0, d, MAX_BUF); + +// unsigned long long st = rdtsc(), en = 0; +// wrk(); +// en = rdtsc(); + +// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); + if (r < 0) printf("E\n"); + else if (r <= 1) printf("D\n"); + else write(1, d, r); + + return 0; +}