-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunimpl.c
37 lines (34 loc) · 1.35 KB
/
unimpl.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
#include <stdio.h> // fprintf stderr
#include <stdlib.h> // calloc
#include <time.h> // timespec clock_gettime CLOCK_MONOTONIC
#include "linux/batch.h" // syscall_t batch
int N[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
16, 20, 24, 32, 36, 40, 44, 50, 60, 70,
80, 90, 100, 128, 256, 384, 1024 };
int main(int ac, char **av) {
struct timespec t0, t1;
unsigned long dt;
int i, j, k, m, nn = sizeof N / sizeof *N;
syscall_t *bat = (syscall_t *)calloc(1024, sizeof *bat);
long *rvs = (long *)calloc(1024, sizeof *rvs);
for (i = 0; i < N[nn - 1]; i++) //Assume last biggest
bat[i].nr = __NR_tuxcall;
printf("N\tm\tns\trs\n");
for (k = 0; k < nn; k++) {
unsigned long min = 1000000000000; //Min out of 10 trials
unsigned long rs = 0;
m = 1000000 / (360 + 46*N[k]); //Make similar real-time
for (i = 0; i < 10; i++) {
clock_gettime(CLOCK_MONOTONIC, &t0);
for (j = 0; j < m; j++)
rs += batch(rvs, bat, N[k], 0, 0);
clock_gettime(CLOCK_MONOTONIC, &t1);
dt = (t1.tv_sec - t0.tv_sec) * 1000000000 +
t1.tv_nsec - t0.tv_nsec;
if (dt < min)
min = dt;
}
printf("%d\t%d\t%ld\t%lu\n", N[k], m, min, rs);
} // NOTE: adjust for user-space loop & gettime overheads
return 0;
} // i7-6700k@4.7GHz ns =~ 370*m + 44*N*m = (370+44*N)*m