I have a ray tracer that renders a simple scene in under a second in release mode, but 25 seconds in debug mode - which is a pain. So I profiled to see what checks were being put in that were taking so long.
A full 12% of the time is being spent in an accessor to a vector, which basically looks:
class Vector
{
float elems[3];
public:
const float_t& operator[](int index) const
{ // 12% time of entire program being spent on this line
return elems[index];
}
}
Disassembly of the prologue to the funtion (second column is percentage of time spent on that line, relative to the entire program):
push ebp 0.2
mov ebp,esp 0.05
push byte ffh 0
push dword 00426fd5h 0.21
mov eax,fs:[00000000h] 0.04
push eax 0
sub esp,00000128h 0.16
push ebx 0.05
push esi 0
push edi 0.22
push ecx 0.09
lea edi,[ebp-00000134h] 0.06
mov ecx,0000004ah 0.14
mov eax,cccccccch 0.03
rep stosd es:[edi] 10.24
pop ecx 0.21
mov eax,[004302a8h] 0.16
xor eax,ebp 0.01
push eax 0.24
lea eax,[ebp-0ch] 0
mov fs:[00000000h],eax 0
mov [ebp-14h],ecx 0.34
Obviously the rep stosd es:[edi] is the line primarily responsible. I'm pretty sure that this is storing a string - what is this string? Having a poke around in memory doesn't reveal anything meaningful, although I guess it could be unicode.