mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 16:58:34 +00:00
C comparison
This commit is contained in:
parent
0965ff479d
commit
20f72ebeae
Binary file not shown.
Binary file not shown.
|
@ -21,6 +21,8 @@
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
clock_t start_t, stop_t;
|
||||
double total_t;
|
||||
lua_State* L= luaL_newstate();
|
||||
|
||||
init_wasm();
|
||||
|
@ -31,5 +33,24 @@ main(int argc, char *argv[])
|
|||
|
||||
call_wasm_function();
|
||||
|
||||
start_t= clock();
|
||||
int test= sum(2,3);
|
||||
stop_t= clock();
|
||||
printf("C sum: %d\n", test);
|
||||
total_t=(double)(stop_t-start_t)/ CLOCKS_PER_SEC;
|
||||
printf("Total time = %f\n", total_t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sum(int start, int length)
|
||||
{
|
||||
int sum = 0, i, j;
|
||||
|
||||
for(j=0; j<10000000; j++){
|
||||
for (i = start; i < start + length; i++) {
|
||||
sum += i;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
|
4
samples/wasm-lua-comparison/src/sum.py
Normal file
4
samples/wasm-lua-comparison/src/sum.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
def sum (start, length):
|
||||
for x in range(0,10000000):
|
||||
sum(x for x in range (start,length))
|
||||
sum(2,3)
|
|
@ -12,7 +12,7 @@
|
|||
function sum(start, length)
|
||||
local sum =0
|
||||
print(start)
|
||||
for x=0,10000000 do
|
||||
for x=0,9999999 do
|
||||
for x=start,(start+length-1) do
|
||||
sum = sum + x;
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user