Mail Archives: djgpp/2002/06/04/12:53:33
"Alex Vinokur" <alexvn AT bigfoot DOT com> wrote in message
news:3CFCDBF9 DOT CCDA33 AT bigfoot DOT com...
> --- 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
I must admit, that I still don't like those results. They still differ by
about 15%. What does the uclock() function, you are using measure. Is it
some "real" time or is it the processor time, the program has actually used.
I tried your code with VC.Net and got results like these (1,000,000
iterations):
Optimizations disabled:
--- automatic uint with OR ---
automatic, OR [1] Total time : 1392
automatic, OR [2] Total time : 1392
automatic, OR [3] Total time : 1402
automatic, OR [4] Total time : 1392
automatic, OR [5] Total time : 1392
automatic, OR [6] Total time : 1392
automatic, OR [7] Total time : 1392
automatic, OR [8] Total time : 1412
automatic, OR [9] Total time : 1402
automatic, OR [10] Total time : 1392
1
--- static uint with PLUS ---
static, PLUS [1] Total time : 651
static, PLUS [2] Total time : 641
static, PLUS [3] Total time : 641
static, PLUS [4] Total time : 631
static, PLUS [5] Total time : 651
static, PLUS [6] Total time : 641
static, PLUS [7] Total time : 651
static, PLUS [8] Total time : 641
static, PLUS [9] Total time : 641
static, PLUS [10] Total time : 651
905032827
Optimized for speed:
--- automatic uint with OR ---
automatic, OR [1] Total time : 511
automatic, OR [2] Total time : 501
automatic, OR [3] Total time : 500
automatic, OR [4] Total time : 501
automatic, OR [5] Total time : 501
automatic, OR [6] Total time : 511
automatic, OR [7] Total time : 500
automatic, OR [8] Total time : 501
automatic, OR [9] Total time : 501
automatic, OR [10] Total time : 500
1
--- static uint with PLUS ---
static, PLUS [1] Total time : 0
static, PLUS [2] Total time : 0
static, PLUS [3] Total time : 0
static, PLUS [4] Total time : 0
static, PLUS [5] Total time : 0
static, PLUS [6] Total time : 0
static, PLUS [7] Total time : 0
static, PLUS [8] Total time : 0
static, PLUS [9] Total time : 0
static, PLUS [10] Total time : 0
905032827
Here, the optimized && (AND, not OR, btw.) is almost three times as fast as
with optimizations turned off, and the 1,000,000 iterations for + cannot be
measured, probably because VC.Net computed the result at compile time. (I
don't know why it didn't do so for &&)
But that doesn't answer your question, and I cannot do so. Common sense
suggests that optimized code should be faster than plain code and if a
compiler slows down a program when optimizing might be a hint that the
compiler does something wrong. Or the uclock() function is not the proper
tool for timing code.
Regards
Heinz
- Raw text -