From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,baaf5f793d03d420 X-Google-Attributes: gid109fba,public X-Google-Thread: fc89c,97188312486d4578 X-Google-Attributes: gidfc89c,public X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,6154de2e240de72a X-Google-Attributes: gid1014db,public From: dik@cwi.nl (Dik T. Winter) Subject: Re: What's the best language to start with? [was: Re: Should I learn C or Pascal?] Date: 1996/08/11 Message-ID: #1/1 X-Deja-AN: 173435528 sender: news@cwi.nl (The Daily Dross) references: <4udb2o$7io@solutions.solon.com> <01bb8569$9910dca0$87ee6fce@timpent.airshields.com> organization: CWI, Amsterdam newsgroups: comp.lang.c,comp.lang.c++,comp.unix.programmer,comp.lang.ada Date: 1996-08-11T00:00:00+00:00 List-Id: In article clodius@hotspec.lanl.gov (William Clodius) writes: > There is one special case of recursion, fortunately the most commonly > encountered case, where it is "ridiculously" easy for a compiler to > see that the recursion can be replaced by iteration. ... Etc. An interesting thread, but I wish to add that I know of at least one system were a recursive algorithm was *significantly faster* than the equivalent one with tail recursion removed. But talking about that "gcd" thingy. I tested and found the following on two different architectures (times are seconds for a complete program): recursive non-recursive arch1, non-opt 0.52 0.42 arch1, opt 0.43 0.41 arch2, non-opt 2.65 0.44 arch2, opt 0.39 0.42 Now, what does this prove? Absolutely nothing (except that there is something strange with the non-optimization on arch2). And what are we talking about anyway? The call was: gcd(2971215073LU, 1836311903LU); (and if you do not understand why I used those numbers, those are the absolutely worst case for 32-bit numbers; Fibonacci, you know). That was the call and it was executed 10,000 times. So we are talking about a routine taking some tens of microseconds. If that would form a large part of a total program (large enough to make a 10% improvement worthwhile), I would bother more about the program. Somebody used the word "microoptimization"; how right he/she was. -- dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924098 home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/