Click here to Skip to main content
15,906,567 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
Hello,

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

myStruct* obj = new myStruct[10001];<br />
memset( obj,0,sizeof(myStruct) * 10005);


Here you actually create 10.001 structs and initialize 10.005! This is very wrong!


Jagadeesh VN wrote:
for( long l=0;l<100000000;l++)<br />
{<br />
obj++;<br />
l1 += obj->index; //just an addition so that compiler wont remove the previous line<br />
<br />
if( i % 10000 == 0 ){<br />
obj = obj1;<br />
l1 = 0; //reseting the values;<br />
}


A couple of questions on this piece of code:
<list>
  • Why the dummy addition (l1 += obj->index;) The compiler won't remove the line, since you use the object further down your code!
  • Why such a long loop?
  • Your loop does nothing usefull, why?
    To get to an answer, I honestly don't think that the long loop is your problem. I think the problem lies with memset(). Let me explain: your execution time drops liniear with the size of the struct. So the size of the array decreases also liniear. (You halve the size of the stuct, so the size of the array is also halved.) So the amount of memory that memset() has to fill is also halved!

    Besides that, your loop executes 100 million times! Don't expect that to finish in a few ms..



    Behind every great black man...
                ... is the police. - Conspiracy brother


    Blog[^]

  • 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 
    GeneralRe: need help!! please help me.. Pin
    Nilesh K.14-Jun-05 0:25
    Nilesh K.14-Jun-05 0:25 
    GeneralRe: need help!! please help me.. Pin
    Christian Graus14-Jun-05 1:21
    protectorChristian Graus14-Jun-05 1:21 

    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.