forked from haiwan/sledge
parent
837fc3a7c0
commit
affe5fbc35
@ -0,0 +1,44 @@
|
||||
#ifndef GET_TIME_H
|
||||
#define GET_TIME_H
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifndef WASM
|
||||
#ifndef CPU_FREQ
|
||||
#define CPU_FREQ 1000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static unsigned long long
|
||||
get_time()
|
||||
{
|
||||
#if 0
|
||||
unsigned long long int ret = 0;
|
||||
unsigned int cycles_lo;
|
||||
unsigned int cycles_hi;
|
||||
__asm__ volatile ("RDTSC" : "=a" (cycles_lo), "=d" (cycles_hi));
|
||||
ret = (unsigned long long int)cycles_hi << 32 | cycles_lo;
|
||||
|
||||
return ret;
|
||||
#else
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
print_time(unsigned long long s, unsigned long long e)
|
||||
{
|
||||
#if 0
|
||||
printf("%llu cycs, %llu us\n", e - s, (e - s) / CPU_FREQ);
|
||||
#else
|
||||
fprintf(stderr, "%llu us\n", e - s);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* GET_TIME_H */
|
@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include "get_time.h"
|
||||
unsigned long int
|
||||
fib(unsigned long int n)
|
||||
{
|
||||
if (n <= 1)
|
||||
return n;
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
unsigned long n = 0, r;
|
||||
scanf("%lu", &n);
|
||||
unsigned long long st = get_time(), en;
|
||||
r = fib(n);
|
||||
en = get_time();
|
||||
printf("%lu\n", r);
|
||||
|
||||
print_time(st, en);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"active" : "yes",
|
||||
"name" : "gocr",
|
||||
"path" : "gocr_wasm.so",
|
||||
"port" : 10000,
|
||||
"argsize" : 1,
|
||||
"http-req-headers" : [ ],
|
||||
"http-req-content-type" : "image/png",
|
||||
"http-req-size": 10240,
|
||||
"http-resp-headers" : [ ],
|
||||
"http-resp-size" : 128,
|
||||
"http-resp-content-type" : "text/plain"
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"active" : "yes",
|
||||
"name" : "lpd",
|
||||
"path" : "lpd_wasm.so",
|
||||
"port" : 10000,
|
||||
"argsize" : 1,
|
||||
"http-req-headers" : [ ],
|
||||
"http-req-content-type" : "image/jpeg",
|
||||
"http-req-size": 102400,
|
||||
"http-resp-headers" : [ ],
|
||||
"http-resp-size" : 1048576,
|
||||
"http-resp-content-type" : "image/jpeg"
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"active" : "yes",
|
||||
"name" : "resize",
|
||||
"path" : "resize_wasm.so",
|
||||
"port" : 10000,
|
||||
"argsize" : 1,
|
||||
"http-req-headers" : [ ],
|
||||
"http-req-content-type" : "image/jpeg",
|
||||
"http-req-size": 102400,
|
||||
"http-resp-headers" : [ ],
|
||||
"http-resp-size" : 102400,
|
||||
"http-resp-content-type" : "image/png"
|
||||
}
|
Loading…
Reference in new issue