11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 30: The Ten Most Important Optional Features of Dev-C++ 391};char *pName;void fn1(Person& p){// create a new object// Person* p1 = new Person(p.pName);Person p1(p);}void fn2(Person p){// create a new objectPerson* p1 = new Person(p);delete p1;}int main(int nNumberofArgs, char* pszArgs[]){Person p(“This_is_a_very_long_name”);}for(int i = 0; i < 1000000; i++){fn1(p);fn2(p);}return 0;This program does nothing more than call fn1() and fn2() millions oftimes — you can’t get an accurate picture of a program that executes in lessthan one second. That’s okay because you don’t need to worry about makinga program that executes in a second or two any faster anyway. Adding theloop causes the program to take a few seconds to complete.In addition, I removed the output statements. You quickly discover that outputis a very slow process. The time spent outputting information to the screenwould have swamped everything else.When executed, the program opened a Console window for a few minutesand then closed the window. Not very exciting so far. I then selectedExecute➪Profile Analysis. The window shown in Figure 30-1 appeared.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!