Added a system calls per second benchmark.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-12-02 12:27:58 +01:00
parent f8129a17b2
commit 5862441351
4 changed files with 42 additions and 1 deletions

View File

@ -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)

1
bench/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.o

26
bench/Makefile Normal file
View File

@ -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

14
bench/benchsyscall.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <stdio.h>
#include <unistd.h>
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;
}