Refer to Windows core programming (fifth edition)
_ Int64 filetimetoquadword (pfiletime PFT)
{
// Convert filetime into _ int64 data
Return (int64shllmod32 (PFT-> dwhighdatetime, 32) | PFT-> dwlowdatetime );
}
Void merge mlongoperation ()
{
Filetime ftkerneltimestart, ftkerneltimeend;
Filetime ftusertimestart, ftusertimeednd;
Filetime ftdummy;
_ Int64 qwkerneltimeelapsed, qwusertimeelapsed, qwtotaltimeelapsed;
Getthreadtimes (getcurrentthread (), & ftdummy, & ftdummy,
& Ftkerneltimestart, & ftusertimestart );
Func (); // calculate the amount of CPU time required by the function
Getthreadtimes (getcurrentthread (), & ftdummy, & ftdummy,
& Ftkerneltimeend, & ftusertimeednd );
// The time used by the kernel. The absolute value of the time used by the operating system code in kernel mode for thread execution, in the unit of NS
Qwkerneltimeelapsed = filetimetoquadword (& ftkerneltimeend)
-Filetimetoquadword (& ftkerneltimestart );
// User time, the absolute value of the time used by the thread to execute the function, in the unit of 100ns
Qwusertimeelapsed = filetimetoquadword (& ftusertimeednd)
-Filetimetoquadword (& ftusertimestart );
// The total CPU time obtained by the previous function
Qwtotaltimeelapsed = qwkerneltimeelapsed + qwusertimeelapsed;
}