Click here to Skip to main content
15,887,856 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCost of a function call Pin
Shah Shehpori10-May-03 8:13
sussShah Shehpori10-May-03 8:13 
GeneralRe: Cost of a function call Pin
Michael Dunn10-May-03 8:50
sitebuilderMichael Dunn10-May-03 8:50 
GeneralRe: Cost of a function call Pin
Joe Woodbury10-May-03 9:18
professionalJoe Woodbury10-May-03 9:18 
GeneralRe: Cost of a function call Pin
S van Leent10-May-03 11:17
S van Leent10-May-03 11:17 
GeneralRe: Cost of a function call Pin
Joe Woodbury10-May-03 12:04
professionalJoe Woodbury10-May-03 12:04 
GeneralRe: Cost of a function call Pin
S van Leent11-May-03 8:17
S van Leent11-May-03 8:17 
GeneralRe: Cost of a function call Pin
Shah Shehpori11-May-03 5:16
sussShah Shehpori11-May-03 5:16 
GeneralRe: Cost of a function call Pin
Joe Woodbury11-May-03 6:10
professionalJoe Woodbury11-May-03 6:10 
At the core, you use the rdtsc x86 instruction. The actual sequence is:

ULARGE_INTEGER cycles;

if (!m_onNT)
    _asm cli

_asm
{
    pushad
    cpuid
    rdtsc
    mov cycles.HighPart,edx
    mov cycles.LowPart,eax
    popad
}

if (!m_onNT)
    _asm sti


You then calculate the overhead of the base test and then time the tests and do analysis (I throw away the top and bottom 20% of the results and average the rest.) You can also calculate the actual speed of the CPU and convert the cycles into seconds. I only do this if I really need to know the time in seconds, otherwise, I just compare cycles.

There are classes posted in CodeProject to help with all this, though I use my own.
GeneralRe: Cost of a function call Pin
Baris Kurtlutepe11-May-03 5:40
Baris Kurtlutepe11-May-03 5:40 
GeneralSocket Error Pin
Mazdak10-May-03 2:31
Mazdak10-May-03 2:31 
GeneralRe: Socket Error Pin
valikac10-May-03 5:42
valikac10-May-03 5:42 
GeneralRe: Socket Error Pin
Mazdak10-May-03 7:47
Mazdak10-May-03 7:47 
GeneralRe: Socket Error Pin
Anders Molin10-May-03 5:43
professionalAnders Molin10-May-03 5:43 
GeneralRe: Socket Error Pin
Mazdak10-May-03 7:48
Mazdak10-May-03 7:48 
GeneralRe: Socket Error Pin
Anders Molin10-May-03 9:18
professionalAnders Molin10-May-03 9:18 
GeneralRe: Socket Error Pin
Mazdak10-May-03 18:05
Mazdak10-May-03 18:05 
QuestionIs ++i statement in the for loop better than i++? Pin
Link260010-May-03 0:56
Link260010-May-03 0:56 
AnswerRe: Is ++i statement in the for loop better than i++? Pin
Tim Smith10-May-03 1:40
Tim Smith10-May-03 1:40 
GeneralRe: Is ++i statement in the for loop better than i++? Pin
Link260010-May-03 12:04
Link260010-May-03 12:04 
GeneralRe: Is ++i statement in the for loop better than i++? Pin
Joe Woodbury11-May-03 6:18
professionalJoe Woodbury11-May-03 6:18 
AnswerRe: Is ++i statement in the for loop better than i++? Pin
valikac10-May-03 5:43
valikac10-May-03 5:43 
AnswerRe: Is ++i statement in the for loop better than i++? Pin
Michael Dunn10-May-03 7:09
sitebuilderMichael Dunn10-May-03 7:09 
GeneralRe: Is ++i statement in the for loop better than i++? Pin
S van Leent10-May-03 11:14
S van Leent10-May-03 11:14 
GeneralRe: Is ++i statement in the for loop better than i++? Pin
Joe Woodbury10-May-03 11:47
professionalJoe Woodbury10-May-03 11:47 
GeneralDLLs Pin
Dominik Reichl9-May-03 22:23
Dominik Reichl9-May-03 22:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.