xref: /haiku/src/tests/system/kernel/syscall_time.cpp (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
1 /*
2  * Copyright 2005, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <OS.h>
8 #include <stdio.h>
9 
10 #ifdef __HAIKU__
11 #	include <syscalls.h>
12 #endif
13 
14 
15 int
16 main(int argc, char **argv)
17 {
18 	const int32 loops = 100000;
19 	bigtime_t startTime = system_time();
20 
21 	for (int32 i = 0; i < loops; i++) {
22 #ifdef __HAIKU__
23 		_kern_is_computer_on();
24 #else
25 		is_computer_on();
26 #endif
27 	}
28 
29 	bigtime_t runTime = system_time() - startTime;
30 
31 	// empty loop time
32 
33 	startTime = system_time();
34 
35 	for (int32 i = 0; i < loops; i++)
36 		;
37 
38 	runTime -= system_time() - startTime;
39 
40 	printf("%f usecs/syscall\n", 1.0 * runTime / loops);
41 	return 0;
42 }
43