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:
@@ -2,10 +2,20 @@ SubDir OBOS_TOP src tests kernel core ;
|
|||||||
|
|
||||||
UsePrivateHeaders kernel ;
|
UsePrivateHeaders kernel ;
|
||||||
|
|
||||||
|
if $(TARGET_PLATFORM) = r5 {
|
||||||
|
LIBROOT = root ;
|
||||||
|
} else {
|
||||||
|
LIBROOT = libroot.so ;
|
||||||
|
}
|
||||||
|
|
||||||
SimpleTest transfer_area_test :
|
SimpleTest transfer_area_test :
|
||||||
transfer_area_test.cpp
|
transfer_area_test.cpp
|
||||||
: libroot.so ;
|
: libroot.so ;
|
||||||
|
|
||||||
|
SimpleTest syscall_time :
|
||||||
|
syscall_time.cpp
|
||||||
|
: $(LIBROOT) ;
|
||||||
|
|
||||||
SubInclude OBOS_TOP src tests kernel core cache ;
|
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 disk_device_manager ;
|
||||||
SubInclude OBOS_TOP src tests kernel core util ;
|
SubInclude OBOS_TOP src tests kernel core util ;
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005, Axel Dörfler, [email protected].
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user