Just for fun, if anyone wants to help.
So I have this little code:
Code:
Stuff::CArray<char> Array;
double max_ = pow(10.0, 8.6);
DWORD dwTick1 = GetTickCount();
int max = (int)max_;
for (int i = 0; i < max; i++)
Array[i] = 12; //12345678;
DWORD dwTick2 = GetTickCount();
DWORD dwTick3 = dwTick2 - dwTick1;
cout << "Took " << dwTick3 << " ms total.\n";
...And I want to optimize it a little further, but it's kind of out of my hands right now.
It's blazingly fast and according to the profiler, the loop is the culprit.
Code:
Address Line Trace Source Code Bytes Total % Timer samples
0x401de6 cmp edi,[esp+14h] 3B 7C 24 14
0x401dea jnz $+15h (0x401dff) 75 13 5.76 218
0x401dec lea esp,[esp+00h] 8D 64 24 00
0x401df0 lea esi,[esp+14h] 8D 74 24 14
0x401df4 call $-00000c24h (0x1004011d0) E8 D7 F3 FF FF
0x401df9 cmp [esp+14h],edi 39 7C 24 14
0x401dfd jbe $-0dh (0x100401df0) 76 F1
0x401dff mov ecx,[esp+24h] 8B 4C 24 24
0x401e03 mov [ecx+edi],0ch C6 04 39 0C 5.61 212
0x401e07 inc edi 47 11.03 417
0x401e08 cmp edi,ebx 3B FB 0.03 1
0x401e0a jl $-24h (0x100401de6) 7C DA 5.24 198
1 file, 1 function, 1 line, 12 instructions, Summary: 1046 samples, 100.00% of module samples, 27.66% of total samples
If anyone have any pointers on how to optimize the loop in assembly? It's blazingly fast considering what it's actually doing, so I just wanted to see how much more performance can be gained through this code, to decrease the execution time from 1.6s to lower!
What it does is a dynamic array that allocates more memory on-the-fly as you insert elements. Considering it's actually adding 10 ^ 8.6 bytes of memory, I say it's pretty efficient!
Pretty please? ^_^
I'm not an assembly expert.