Reputation: 141
On Linux it seems getpid()
is the simplest system call to invoke to best-measure the time taken for a system call. Would somebody be able to refer me to a simple windows system call I could make to measure the time spent changing to kernel mode and back please?
I did google and found a list of Windows System calls on MSDN website, but they all referred to opening files- which seemed strange:
http://msdn.microsoft.com/en-us/library/t0wd4t32.aspx
I am on Windows 7 64 bit.
Upvotes: 2
Views: 1011
Reputation: 210755
My suggestion (and this is just based on intuition) is to try something like
CloseHandle(NULL)
or
WaitForMultipleObjectsEx(0, NULL, 0, 0, FALSE)
on the grounds that it should be a no-op. However, I don't have any evidence to support this.
A little benchmarking on Win8.1 x64 shows the (undocumented) NtDisplayString(NULL)
function is even faster, followed by the semi-documented NtAllocateLocallyUniqueId(&some_luid)
. You'll have to dynamically load them from NTDLL using GetProcAddress
; the signatures are:
NTSTATUS NTAPI PNtAllocateLocallyUniqueId(PLUID LUID);
NTSTATUS NTAPI PNtDisplayString(PUNICODE_STRING DisplayString);
Upvotes: 1