Show More
Commit Description:
add a new modified sandbox "box"...
Commit Description:
add a new modified sandbox "box" The original file was pulled from moe (git://git.ucw.cz/moe.git) by Martin Mares's commit on Sun Jul 29 23:53:56 2012 +0200 The modification is to make it separately compilable and add more option to specify additional argument to the program. (Please see usage guide) run `gcc -o box -std=c99 box64-new.c` to compile.
File last commit:
Show/Diff file:
Action:
test/data/test2_05sec.c | 40 lines | 629 B | text/x-c | CLexer |
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include <sys/resource.h>
// run it for 1.5 s
int main()
{
int a,b;
int c=0;
int r;
r = scanf("%d %d",&a,&b);
printf("%d\n",a+b);
struct rusage ru;
while(1) {
c++;
b+=c;
while(c<100000) {
c++;
b+=c;
}
getrusage(RUSAGE_SELF,&ru);
double rtime = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec;
rtime += (double)ru.ru_utime.tv_usec / 1000000.0;
rtime += (double)ru.ru_stime.tv_usec / 1000000.0;
if(rtime > 0.5)
break;
}
printf("%d\n",b);
a += r;
exit(0);
}