Click here to Skip to main content
15,897,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How is go on? Pin
David Crow14-Jun-05 11:02
David Crow14-Jun-05 11:02 
GeneralTest Site: Pin
lewislewis_lewis14-Jun-05 11:11
lewislewis_lewis14-Jun-05 11:11 
GeneralRe: Test Site: Pin
David Crow15-Jun-05 3:35
David Crow15-Jun-05 3:35 
GeneralThanks You every much,. but have somequestion? Pin
lewislewis_lewis15-Jun-05 5:25
lewislewis_lewis15-Jun-05 5:25 
GeneralDisabling toolbutton Pin
laiju14-Jun-05 0:20
laiju14-Jun-05 0:20 
GeneralRe: Disabling toolbutton Pin
David Crow14-Jun-05 1:33
David Crow14-Jun-05 1:33 
GeneralRe: Disabling toolbutton Pin
laiju17-Jun-05 0:32
laiju17-Jun-05 0:32 
GeneralA very small performance issue in C++ Pin
Jagadeesh VN14-Jun-05 2:27
Jagadeesh VN14-Jun-05 2:27 
Hi,

I have a query on pointer arithmetic.

I declared a structure like this

struct myStruct{
int index;
char sz[124];
};

Inside the main(), I created 10000 objects of the structure and assigned it to a pointer variable.

myStruct* obj = new myStruct[10001];
memset( obj,0,sizeof(myStruct) * 10005);
myStruct* obj1 = obj;
long l1 = 0;

for( long l=0;l<100000000;l++)
{
obj++;
l1 += obj->index; //just an addition so that compiler wont remove the previous line

if( i % 10000 == 0 ){
obj = obj1;
l1 = 0; //reseting the values;
}

}

When I executed this, it took me 8 sec.

But if I reduce the size of myStruct to 64, it takes only 4 sec.
ie.
struct myStruct{
int index;
char sz[60];
};

and again reducing the size to 32, it takes only 2 secs.

I examined the assembly code which was generated by Disassembly, and the only change was in the 2nd line

obj++;
mov edx,dword ptr [ebp-14h]
add edx,100h
mov dword ptr [ebp-14h],edx

thats in
add edx,100h ( 256 b ) time : 8sec
add edx,20h ( 32 b ) time : 2sec

Can anybody pl. give me an explanation for this behaviour.

I was able to reproduce this behaviour in Unix also....

Thanks and Regards
Jagadeesh

"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
GeneralRe: A very small performance issue in C++ Pin
Dezhi Zhao14-Jun-05 3:32
Dezhi Zhao14-Jun-05 3:32 
GeneralRe: A very small performance issue in C++ Pin
Bob Stanneveld14-Jun-05 1:28
Bob Stanneveld14-Jun-05 1:28 
Generalcopy jpg to clipboard Pin
Stirfie14-Jun-05 2:08
Stirfie14-Jun-05 2:08 
GeneralRe: copy jpg to clipboard Pin
David Crow14-Jun-05 3:12
David Crow14-Jun-05 3:12 
GeneralRe: copy jpg to clipboard Pin
Stirfie14-Jun-05 23:24
Stirfie14-Jun-05 23:24 
GeneralRe: copy jpg to clipboard Pin
David Crow15-Jun-05 3:09
David Crow15-Jun-05 3:09 
Generalsaving a bitmap Pin
Arrun14-Jun-05 1:30
Arrun14-Jun-05 1:30 
GeneralRe: saving a bitmap Pin
Christian Graus14-Jun-05 2:01
protectorChristian Graus14-Jun-05 2:01 
Generalconverting byte to bit Pin
Arrun14-Jun-05 1:24
Arrun14-Jun-05 1:24 
GeneralRe: converting byte to bit Pin
Christian Graus14-Jun-05 1:29
protectorChristian Graus14-Jun-05 1:29 
GeneralRe: converting byte to bit Pin
PJ Arends14-Jun-05 7:08
professionalPJ Arends14-Jun-05 7:08 
GeneralRe: converting byte to bit Pin
Christian Graus14-Jun-05 13:49
protectorChristian Graus14-Jun-05 13:49 
Questionhow to debug a helper object? Pin
ThinkingPrometheus14-Jun-05 0:54
ThinkingPrometheus14-Jun-05 0:54 
GeneralRelease in _RecordsetPtr Pin
Anonymous14-Jun-05 0:36
Anonymous14-Jun-05 0:36 
GeneralShell Extension On 64 bit Windows XP Pin
Bond0414-Jun-05 0:10
Bond0414-Jun-05 0:10 
Generalneed help!! please help me.. Pin
c_ngo13-Jun-05 20:39
c_ngo13-Jun-05 20:39 
GeneralRe: need help!! please help me.. Pin
Bob Stanneveld13-Jun-05 23:51
Bob Stanneveld13-Jun-05 23:51 

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.