Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Irv Mullins <irv at ELLIJAY.COM> Feb 17, 2000
- 727 views
On Thu, 17 Feb 2000, you wrote: > Irv Mullins wrote: re: > >> printf(file_number, > >> "%04x%04x%04x%04x%04x%04x%04x%04x%04x%04x", > >> {final[ 1],final[ 2],final[ 3],final[ 4],final[ 5], > >> final[ 6],final[ 7],final[ 8],final[ 9],final[10]}) > >> > >> printf(file_number, > >> "%04x%04x%04x%04x%04x%04x%04x%04x%04x%04x\n", > >> {final[11],final[12],final[13],final[14],final[15], > >> final[16],final[17],final[18],final[19],final[20]}) vs: printf(file_number, fmt, final) Everett wrote: > Certainly, it would be theoretically faster to move the creation of fmt > outside > the loop, but any compiler with any kind of optimizing capability will take > any literal like this and treat it like a constant and move it outside the > loop. Apparently, that is what Euphoria does. There is no measurable difference in execution time between a using a constant or using a literal. (less than 1%) > The use of a variable will cause the compiler to have to check the value of > fmt every time it sees it. > The fastest way would be to create the value and > assign it to fmt as a constant. One would think so, however, there is no measurable difference between using a constant and using a sequence. Again, less than 1%. <snip> > This is probably a handicap of the aged and infirm programmer, but > complexity is oft in the eye of the beholder. It might be noted, as in the > case of COBOL, verbose does not equal complex, or even, in most cases, > less efficient. Also, with modern editors, I didn't type any of those > variable names but once...the rest was cut and paste. The advantage to > being verbose, where it does not effect performance is that it offers > the opportunity to easily alter what is written. Exception code many times > just becomes a different coding of an explicit sequence. Where the code > becomes large and untenable due to explicit coding, I will agree with your > correction. Otherwise, being straightforward has it's advantages. True again, except that the de-referencing of members of a sequence x[1], x[2],x[3].... etc, does affect performance: There's a 10 - 15% increase in execution time when applied to this list of 20. Regards, Irv