From: Alex Vinokur Newsgroups: comp.os.msdos.djgpp,comp.lang.c++ Subject: Re: Optimization and operator&& Date: Tue, 04 Jun 2002 17:25:45 +0200 Lines: 309 Message-ID: <3CFCDBF9.CCDA33@bigfoot.com> References: <3CFCB642 DOT 252CFFF7 AT bigfoot DOT com> NNTP-Posting-Host: gateway.scopus.net (62.90.123.5) Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1023200627 34729187 62.90.123.5 (16 [79865]) X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Heinz Ozwirk wrote: > "Alex Vinokur" wrote in message > news:3CFCB642 DOT 252CFFF7 AT bigfoot DOT com... > > > > ############### > > Windows98 > > gcc/gpp 2.95.3 > > ############### > > > > > > A program below measures performance (time) : > > * of operator&& and operator+ > > * with automatic and static unsigned int > > * with optimizations : No optimization, O1, O2, O3 > > > > We can see that Optimization causes > > an increase in elapsed time for operator&& . > > Any explanation? > ... > [snip] > > ... > > Your results are useless. They differ by about 25%. Probably the resolution > of your timer is too large (or your processor is too fast). Run your tests > again, but this time measure at least 10,000,000 iterations. > > Regards > Heinz Here are results with 10,000,000 iterations. || ###### Compilation & Run : BEGIN ######## || No optimization %gpp main.c -o a0.exe %a0 --- static uint with OR --- static, OR [1] Total time : 186986 static, OR [2] Total time : 187100 static, OR [3] Total time : 181918 static, OR [4] Total time : 193440 static, OR [5] Total time : 177352 static, OR [6] Total time : 182445 static, OR [7] Total time : 185969 static, OR [8] Total time : 204047 static, OR [9] Total time : 176972 static, OR [10] Total time : 191458 1 --- automatic uint with OR --- automatic, OR [1] Total time : 155021 automatic, OR [2] Total time : 162307 automatic, OR [3] Total time : 161321 automatic, OR [4] Total time : 158908 automatic, OR [5] Total time : 155007 automatic, OR [6] Total time : 163801 automatic, OR [7] Total time : 156468 automatic, OR [8] Total time : 179410 automatic, OR [9] Total time : 153427 automatic, OR [10] Total time : 159329 1 --- static uint with PLUS --- static, PLUS [1] Total time : 130308 static, PLUS [2] Total time : 168823 static, PLUS [3] Total time : 159669 static, PLUS [4] Total time : 167224 static, PLUS [5] Total time : 162690 static, PLUS [6] Total time : 159877 static, PLUS [7] Total time : 166417 static, PLUS [8] Total time : 168937 static, PLUS [9] Total time : 192566 static, PLUS [10] Total time : 143504 520000123 --- automatic uint with PLUS --- automatic, PLUS [1] Total time : 118877 automatic, PLUS [2] Total time : 172795 automatic, PLUS [3] Total time : 130224 automatic, PLUS [4] Total time : 172183 automatic, PLUS [5] Total time : 179725 automatic, PLUS [6] Total time : 132234 automatic, PLUS [7] Total time : 162603 automatic, PLUS [8] Total time : 168805 automatic, PLUS [9] Total time : 158866 automatic, PLUS [10] Total time : 101873 520000123 || No optimization || ###### Compilation & Run : END ########## || ###### Compilation & Run : BEGIN ######## || Optimization O1 %gpp -O1 main.c -o a1.exe %a1 --- static uint with OR --- static, OR [1] Total time : 266250 static, OR [2] Total time : 266729 static, OR [3] Total time : 264779 static, OR [4] Total time : 265749 static, OR [5] Total time : 267403 static, OR [6] Total time : 285114 static, OR [7] Total time : 267340 static, OR [8] Total time : 266558 static, OR [9] Total time : 265249 static, OR [10] Total time : 267702 1 --- automatic uint with OR --- automatic, OR [1] Total time : 206321 automatic, OR [2] Total time : 203833 automatic, OR [3] Total time : 203991 automatic, OR [4] Total time : 202252 automatic, OR [5] Total time : 208034 automatic, OR [6] Total time : 230505 automatic, OR [7] Total time : 204599 automatic, OR [8] Total time : 204595 automatic, OR [9] Total time : 206029 automatic, OR [10] Total time : 202169 1 --- static uint with PLUS --- static, PLUS [1] Total time : 108653 static, PLUS [2] Total time : 85620 static, PLUS [3] Total time : 107325 static, PLUS [4] Total time : 82642 static, PLUS [5] Total time : 101233 static, PLUS [6] Total time : 69925 static, PLUS [7] Total time : 74159 static, PLUS [8] Total time : 83076 static, PLUS [9] Total time : 121495 static, PLUS [10] Total time : 91547 520000123 --- automatic uint with PLUS --- automatic, PLUS [1] Total time : 120268 automatic, PLUS [2] Total time : 108772 automatic, PLUS [3] Total time : 85033 automatic, PLUS [4] Total time : 71257 automatic, PLUS [5] Total time : 113443 automatic, PLUS [6] Total time : 92257 automatic, PLUS [7] Total time : 120099 automatic, PLUS [8] Total time : 110701 automatic, PLUS [9] Total time : 88308 automatic, PLUS [10] Total time : 113803 520000123 || Optimization O1 || ###### Compilation & Run : END ########## || ###### Compilation & Run : BEGIN ######## || Optimization O2 %gpp -O2 main.c -o a2.exe %a2 --- static uint with OR --- static, OR [1] Total time : 265420 static, OR [2] Total time : 265139 static, OR [3] Total time : 266852 static, OR [4] Total time : 289894 static, OR [5] Total time : 267484 static, OR [6] Total time : 269460 static, OR [7] Total time : 271028 static, OR [8] Total time : 276708 static, OR [9] Total time : 264799 static, OR [10] Total time : 266163 1 --- automatic uint with OR --- automatic, OR [1] Total time : 216503 automatic, OR [2] Total time : 199450 automatic, OR [3] Total time : 198319 automatic, OR [4] Total time : 202438 automatic, OR [5] Total time : 196483 automatic, OR [6] Total time : 195153 automatic, OR [7] Total time : 229314 automatic, OR [8] Total time : 196878 automatic, OR [9] Total time : 198165 automatic, OR [10] Total time : 200474 1 --- static uint with PLUS --- static, PLUS [1] Total time : 118224 static, PLUS [2] Total time : 77882 static, PLUS [3] Total time : 90267 static, PLUS [4] Total time : 117555 static, PLUS [5] Total time : 103510 static, PLUS [6] Total time : 73175 static, PLUS [7] Total time : 82098 static, PLUS [8] Total time : 122037 static, PLUS [9] Total time : 89492 static, PLUS [10] Total time : 117505 520000123 --- automatic uint with PLUS --- automatic, PLUS [1] Total time : 43896 automatic, PLUS [2] Total time : 43496 automatic, PLUS [3] Total time : 44762 automatic, PLUS [4] Total time : 44905 automatic, PLUS [5] Total time : 43497 automatic, PLUS [6] Total time : 44764 automatic, PLUS [7] Total time : 46072 automatic, PLUS [8] Total time : 43496 automatic, PLUS [9] Total time : 44183 automatic, PLUS [10] Total time : 44672 520000123 || Optimization O2 || ###### Compilation & Run : END ########## || ###### Compilation & Run : BEGIN ######## || Optimization O3 %gpp -O3 main.c -o a3.exe %a3 --- static uint with OR --- static, OR [1] Total time : 264211 static, OR [2] Total time : 296462 static, OR [3] Total time : 267027 static, OR [4] Total time : 265602 static, OR [5] Total time : 266299 static, OR [6] Total time : 265855 static, OR [7] Total time : 267083 static, OR [8] Total time : 285704 static, OR [9] Total time : 266744 static, OR [10] Total time : 272728 1 --- automatic uint with OR --- automatic, OR [1] Total time : 196533 automatic, OR [2] Total time : 197453 automatic, OR [3] Total time : 199607 automatic, OR [4] Total time : 223342 automatic, OR [5] Total time : 197136 automatic, OR [6] Total time : 194653 automatic, OR [7] Total time : 203098 automatic, OR [8] Total time : 198691 automatic, OR [9] Total time : 193992 automatic, OR [10] Total time : 194465 1 --- static uint with PLUS --- static, PLUS [1] Total time : 134800 static, PLUS [2] Total time : 74704 static, PLUS [3] Total time : 84592 static, PLUS [4] Total time : 99971 static, PLUS [5] Total time : 72234 static, PLUS [6] Total time : 79407 static, PLUS [7] Total time : 99243 static, PLUS [8] Total time : 150875 static, PLUS [9] Total time : 82086 static, PLUS [10] Total time : 100408 520000123 --- automatic uint with PLUS --- automatic, PLUS [1] Total time : 43496 automatic, PLUS [2] Total time : 45323 automatic, PLUS [3] Total time : 44284 automatic, PLUS [4] Total time : 43496 automatic, PLUS [5] Total time : 44383 automatic, PLUS [6] Total time : 43882 automatic, PLUS [7] Total time : 43632 automatic, PLUS [8] Total time : 44628 automatic, PLUS [9] Total time : 43907 automatic, PLUS [10] Total time : 43496 520000123 || Optimization O3 || ###### Compilation & Run : END ########## Regards, =========================== Alex Vinokur mailto:alexvn AT bigfoot DOT com mailto:alexvn AT go DOT to http://up.to/alexvn http://go.to/alexv_math ===========================