diff --git a/Makefile b/Makefile index f5de498a..e95b09d6 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ endif REMOTE=192.168.2.6 REMOTEUSER=sortie REMOTECOPYDIR:=/home/$(REMOTEUSER)/Desktop/MaxsiOS -MODULES=libmaxsi games mkinitrd utils sortix +MODULES=libmaxsi games mkinitrd utils bench sortix VERSION=0.5dev DEBNAME:=sortix_$(VERSION)_$(CPU) diff --git a/bench/.gitignore b/bench/.gitignore new file mode 100644 index 00000000..5761abcf --- /dev/null +++ b/bench/.gitignore @@ -0,0 +1 @@ +*.o diff --git a/bench/Makefile b/bench/Makefile new file mode 100644 index 00000000..88aa51c5 --- /dev/null +++ b/bench/Makefile @@ -0,0 +1,26 @@ +# Set up variables such that we can easily cross-compile. +OSROOT=.. +include ../crosscompilemakefile.mak + +INITRDDIR:=../initrd +LOCALBINARIES:=\ +benchsyscall \ + +BINARIES:=$(addprefix $(INITRDDIR)/,$(LOCALBINARIES)) + +all: install + +install: $(LOCALBINARIES) + cp $(LOCALBINARIES) $(INITRDDIR) + rm -f $(LOCALBINARIES) + +%: %.cpp + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -O2 -c $< -o $@.o + $(LD) $(LDFLAGS) $@.o -o $@ $(LIBS) + +sh: mxsh + cp $< $@ + +clean: + rm -f $(BINARIES) $(LOCALBINARIES) *.o + diff --git a/bench/benchsyscall.cpp b/bench/benchsyscall.cpp new file mode 100644 index 00000000..1201b106 --- /dev/null +++ b/bench/benchsyscall.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + uintmax_t start; + if ( uptime(&start) ) { perror("uptime"); return 1; } + uintmax_t end = start + 1ULL * 1000ULL; // 1 second + size_t count = 0; + uintmax_t now; + while ( !uptime(&now) && now < end ) { count++; } + printf("Made %zu system calls in 1 second\n", count); + return 0; +}