aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/spawn
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-11-02 16:19:11 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-11-02 16:19:11 +0200
commit010152de4f19fcb4f1b627123aa27f08deb13e72 (patch)
tree44a8b65c4d1af8f90c2d7912d000954caad14585 /benchmarks/spawn
parent21efbba39340300a7ba9d5f4f94017f5ff956833 (diff)
downloadkmi-010152de4f19fcb4f1b627123aa27f08deb13e72.tar.gz
kmi-010152de4f19fcb4f1b627123aa27f08deb13e72.zip
add spawn benchmark
Diffstat (limited to 'benchmarks/spawn')
-rw-r--r--benchmarks/spawn/init.c46
-rw-r--r--benchmarks/spawn/source.mk1
-rw-r--r--benchmarks/spawn/spawn.c14
3 files changed, 61 insertions, 0 deletions
diff --git a/benchmarks/spawn/init.c b/benchmarks/spawn/init.c
new file mode 100644
index 0000000..d4c2504
--- /dev/null
+++ b/benchmarks/spawn/init.c
@@ -0,0 +1,46 @@
+#include <common/benchmark.h>
+#include <common/cpio.h>
+
+void callback()
+{
+ sys_exit(1);
+}
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ UNUSED(pid);
+ UNUSED(tid);
+ UNUSED(d0);
+ UNUSED(d1);
+ UNUSED(d2);
+ UNUSED(d3);
+
+ if (d0 == SYS_USER_ORPHANED) {
+ sys_exit(1);
+ }
+
+ printf("finding spawn in cpio archive %lx...\n", d2);
+ struct cpio_header *cp = cpio_find_file((const void *)d2,
+ "spawn", sizeof("spawn") - 1);
+
+ if (!cp) {
+ printf("couldn't find spawn?\n");
+ report(0, 0, 0);
+ }
+
+ long name_len = convnum(cp->c_namesize, 8, 16);
+ uintptr_t spawn = (uintptr_t)(cp) + align_up(sizeof(struct cpio_header) + name_len, 4);
+ printf("found spawn at %lx\n", spawn);
+
+ uint64_t timebase = sys_timebase();
+ uint64_t start = sys_ticks();
+
+ for (size_t i = 0; i < 1000; ++i) {
+ id_t new_id = sys_spawn(spawn, 0);
+ sys_detach(new_id);
+ sys_swap(new_id);
+ }
+
+ uint64_t end = sys_ticks();
+ report(start, end, timebase);
+}
diff --git a/benchmarks/spawn/source.mk b/benchmarks/spawn/source.mk
new file mode 100644
index 0000000..20ce8d4
--- /dev/null
+++ b/benchmarks/spawn/source.mk
@@ -0,0 +1 @@
+DO != ./scripts/gen-benchmark -n spawn -p init -p spawn
diff --git a/benchmarks/spawn/spawn.c b/benchmarks/spawn/spawn.c
new file mode 100644
index 0000000..c6a2f8e
--- /dev/null
+++ b/benchmarks/spawn/spawn.c
@@ -0,0 +1,14 @@
+#include <common/benchmark.h>
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ UNUSED(pid);
+ UNUSED(tid);
+ UNUSED(d0);
+ UNUSED(d1);
+ UNUSED(d2);
+ UNUSED(d3);
+
+ printf("not sure how we got here?\n");
+ /* die or something */
+}