aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/fork/init.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-08-30 18:56:49 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-08-30 18:56:49 +0300
commit1a2e1fff7ce4b8fd8db46549d81e71e76b842da3 (patch)
treee33fa259bf9de49e589dd1e75a95dcd09ad3bc97 /benchmarks/fork/init.c
parentec30538a81c0e900797f4d88c1ee059afa7d9617 (diff)
downloadkmi-1a2e1fff7ce4b8fd8db46549d81e71e76b842da3.tar.gz
kmi-1a2e1fff7ce4b8fd8db46549d81e71e76b842da3.zip
add some basic benchmarks
Diffstat (limited to 'benchmarks/fork/init.c')
-rw-r--r--benchmarks/fork/init.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/benchmarks/fork/init.c b/benchmarks/fork/init.c
new file mode 100644
index 0000000..95f6466
--- /dev/null
+++ b/benchmarks/fork/init.c
@@ -0,0 +1,27 @@
+#include <common/benchmark.h>
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ UNUSED(pid);
+ UNUSED(tid);
+ UNUSED(d0);
+ UNUSED(d1);
+ UNUSED(d2);
+ UNUSED(d3);
+
+ uint64_t timebase = sys_timebase();
+ uint64_t start = sys_ticks();
+
+ for (size_t i = 0; i < 1000; ++i) {
+ id_t our_tid = 0;
+ id_t new_id = sys_fork(&our_tid);
+ if (new_id == 0) {
+ /* child instantly dies */
+ sys_exit(1);
+ }
+ sys_swap(new_id);
+ }
+
+ uint64_t end = sys_ticks();
+ report(start, end, timebase);
+}