Added a syscall timing utility, similar to the one in NewOS.

Can also be run under R5 when TARGET_PLATFORM=r5 for comparison.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12567 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-05-04 01:03:44 +00:00
parent a3b4fd6b87
commit 5514672d42
2 changed files with 55 additions and 0 deletions

View File

@ -2,10 +2,20 @@ SubDir OBOS_TOP src tests kernel core ;
UsePrivateHeaders kernel ;
if $(TARGET_PLATFORM) = r5 {
LIBROOT = root ;
} else {
LIBROOT = libroot.so ;
}
SimpleTest transfer_area_test :
transfer_area_test.cpp
: libroot.so ;
SimpleTest syscall_time :
syscall_time.cpp
: $(LIBROOT) ;
SubInclude OBOS_TOP src tests kernel core cache ;
#SubInclude OBOS_TOP src tests kernel core disk_device_manager ;
SubInclude OBOS_TOP src tests kernel core util ;

View File

@ -0,0 +1,45 @@
/*
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include <OS.h>
#include <stdio.h>
#ifdef __HAIKU__
# include <syscalls.h>
#else
extern "C" void _kclose_(int fd);
#endif
int
main(int argc, char **argv)
{
const int32 loops = 100000;
bigtime_t startTime = system_time();
for (int32 i = 0; i < loops; i++) {
#ifdef __HAIKU__
// _kern_null();
_kern_close(-1);
#else
_kclose_(-1);
#endif
}
bigtime_t runTime = system_time() - startTime;
// empty loop time
startTime = system_time();
for (int32 i = 0; i < loops; i++)
;
runTime -= system_time() - startTime;
printf("%f usecs/syscall\n", 1.0 * runTime / loops);
return 0;
}