forked from nekin2012/btest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.c
58 lines (43 loc) · 1 KB
/
ci.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <getopt.h>
#include "cal.h"
#include "misc.h"
int cfg_size=1000000; /* in pages */
int cfg_unit=100; /* in pages */
static long time1=0, time2=0;
void int_handler(int signum) {
time2 = get_timestamp();
printf("exit\nstat:\n");
printf("break in %ldus\n", time2-time1);
exit(signum);
}
void parse_opt(int argc, char * argv[]) {
int opt;
while((opt=getopt(argc, argv, "s:u:")) != -1) {
switch(opt) {
PARSE_ARG_I('s', cfg_size);
PARSE_ARG_I('u', cfg_unit);
default:
fprintf(stderr, "usage: %s [-s size] [-u unit]",
argv[0]);
exit(0);
}
}
}
int main(int argc, char *argv[]) {
int i;
parse_opt(argc, argv);
DIE_IF(!cfg_unit, "cfg_unit");
DIE_IF(!cfg_size, "cfg_unit");
signal(SIGINT, int_handler);
time1 = get_timestamp();
for(i=0; i<cfg_size/cfg_unit; i++) {
heavy_mem_write(cfg_unit);
}
time2 = get_timestamp();
printf("finish in %ldus\n", time2-time1);
return EXIT_SUCCESS;
}