Created
November 28, 2019 09:42
-
-
Save LennyLip/ba5b567ac680c89e62dd010934d55abd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <emscripten.h> | |
// #include <stdio.h> | |
#include <stdlib.h> | |
char str[] = "Function from C (Web Assemblly) called!"; | |
EMSCRIPTEN_KEEPALIVE | |
char* functionFromC () { | |
return &str[0]; | |
} | |
EMSCRIPTEN_KEEPALIVE | |
double loadTest () { | |
// clock_t start, end; | |
int start, end; | |
double cpu_time_used; | |
int num = 1, primes = 0; | |
int limit = 150000; | |
// don't work | |
// start = emscripten_get_now(); | |
for (num = 1; num <= limit; num++) { | |
int i = 2; | |
while(i <= num) { | |
if(num % i == 0) | |
break; | |
i++; | |
} | |
if(i == num) | |
primes++; | |
} | |
return primes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment