Last active
June 28, 2023 00:31
-
-
Save avagin/1dbd7736083e9fe1ad0983832858d7aa to your computer and use it in GitHub Desktop.
This file contains 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
# cat syscall_bench.c | |
#define _GNU_SOURCE | |
#include <asm/unistd_64.h> | |
#include <sys/types.h> | |
#include <sys/wait.h> | |
#include <sys/syscall.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) | |
{ | |
int n_threads = atoi(argv[2]), n_syscalls = atoi(argv[1]); | |
unsigned long long i, j; | |
int status; | |
pid_t pid; | |
for (j = 0; j < n_threads - 1; j++) { | |
pid = fork(); | |
if (pid < 0) | |
return 1; | |
if (pid == 0) | |
break; | |
} | |
for (i = 0; i < n_syscalls; i++) { | |
syscall(__NR_clock_gettime, 1 << 31, NULL); | |
} | |
if (pid != 0) { | |
for (j = 0; j < n_threads - 1; j++) { | |
if (wait(&status) == -1 || status != 0) { | |
return 1; | |
} | |
} | |
} | |
printf("done\n"); | |
while (1) | |
sleep(1000); | |
return 0; | |
} | |
# gcc -Wall syscall_bench.c -o syscall_bench | |
# pgrep 'exe' | grep -v 2273389 | xargs -I '{}' cat /proc/{}/stat | awk '{print $14*10 " " $15*10; a+=$14+$15;} END { print "=" a*10 }' | |
=0 | |
# n=1; for i in `seq $n`; do ./runsc --ignore-cgroups --network none do ./syscall_bench 1000000 2 & done | |
[1] 1782356 | |
# done | |
# pgrep 'exe' | grep -v 2273389 | xargs -I '{}' cat /proc/{}/stat | awk '{print $14*10 " " $15*10; a+=$14+$15;} END { print "=" a*10 }' | |
120 20 | |
6460 540 | |
0 0 | |
0 0 | |
0 0 | |
3550 2000 | |
0 0 | |
3530 2060 | |
=18280 | |
# kill %1 | |
# | |
[1]+ Exit 143 ./runsc --ignore-cgroups --network none do ./syscall_bench 1000000 2 | |
# pgrep 'exe' | grep -v 2273389 | xargs -I '{}' cat /proc/{}/stat | awk '{print $14*10 " " $15*10; a+=$14+$15;} END { print "=" a*10 }' | |
=0 | |
# | |
# n=2; for i in `seq $n`; do ./runsc --ignore-cgroups --network none do ./syscall_bench 1000000 2 & done | |
[1] 1782528 | |
[2] 1782529 | |
# done | |
done | |
# pgrep 'exe' | grep -v 2273389 | xargs -I '{}' cat /proc/{}/stat | awk '{print $14*10 " " $15*10; a+=$14+$15;} END { print "=" a*10 }' | |
80 30 | |
80 20 | |
4960 190 | |
5260 180 | |
0 0 | |
0 0 | |
0 0 | |
0 0 | |
0 0 | |
2300 1930 | |
0 0 | |
2510 1820 | |
0 0 | |
2420 1790 | |
0 0 | |
2390 1910 | |
=27870 | |
# kill %2 | |
# kill %1 | |
[2]+ Exit 143 ./runsc --ignore-cgroups --network none do ./syscall_bench 1000000 2 | |
# | |
[1]+ Exit 143 ./runsc --ignore-cgroups --network none do ./syscall_bench 1000000 2 | |
# pgrep 'exe' | grep -v 2273389 | xargs -I '{}' cat /proc/{}/stat | awk '{print $14*10 " " $15*10; a+=$14+$15;} END { print "=" a*10 }' | |
=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment