mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added a system calls per second benchmark.
This commit is contained in:
parent
f8129a17b2
commit
5862441351
4 changed files with 42 additions and 1 deletions
2
Makefile
2
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)
|
||||
|
|
1
bench/.gitignore
vendored
Normal file
1
bench/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.o
|
26
bench/Makefile
Normal file
26
bench/Makefile
Normal 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
14
bench/benchsyscall.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue