Archived

This topic is now archived and is closed to further replies.

time...to multiply

This topic is 5966 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

anyone know offhand how long the C/C++ function exp() takes compared to a recursive function? anyone know offhand how long the C/C++ function exp() takes when it''s a power of two compared to multiplying only? I know I know, measure time before and after, but I''m always interested in seeing how mid to high level language functions are transformed into low level machine code Create.

Share this post


Link to post
Share on other sites
You can make MSVC, and most other compilers too, generate a text file with the asm code in it that you can review, for both debug and release builds. Whenever I''m curious I just pop open the Disammebly debug window.

...
You can use the RTDSC op code on modern pentiums to time how long anything takes in CPU clock ticks. Keep in mind that this will include any time spent in another thread if you get swapped out and when the CPU handles any interrupts.

Recursion generally blows, it''s usefulness is in the high-level trees, not in algorithms.

  
__int64 __declspec( naked ) RDTSC()
{
_asm
{
//Prolog

push ebp
mov ebp, esp
sub esp, __LOCAL_SIZE

//Get CPU Ticks

//xor eax, eax

//xor ebx, ebx

//xor ecx, ecx

//xor edx, edx

_emit 0x0f // RDTSC returns cpu ticks in edx:eax

_emit 0x31


//Epilog

mov esp, ebp
pop ebp
ret
}
}


Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites