Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Julian Fondren Newsgroups: comp.lang.forth Subject: Re: Forth Performance Question Date: Sun, 07 Aug 2011 01:01:11 -0500 Organization: A noiseless patient Spider Lines: 62 Message-ID: <86r54x4v6g.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="cO8zBIpB9LiP7q+vFZIJrA"; logging-data="10807"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18a/xbcX7uXyfyOX/TRPOZpG2quGP3legA=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) Cancel-Lock: sha1:6sFOclXOgku0UvcLCzmvmYX+0tE= sha1:TIkLpjmQ+clBZVZ1RHsFWehKBfQ= Xref: x330-a1.tempe.blueboxinc.net comp.lang.forth:4630 TS writes: > Hi, (This guy's posting from Google Groups, a web interface for Usenet run by a company that's too inept even to announce to their own users that their service is having problems. I already sent him an email to warn him to look for replies in other venues.) > I'm just starting to learn Forth, and trying to assess the performance > differences between some of the common free Forths. I ran this > program: > : foo 1 1000000 * drop ; > : test 1 100000000 ?DO foo LOOP ; > > On BigForth 2.4.0 it took ~22 sec to run, Retro v11 (with "times" > syntax, compiled with -O3), took ~23 sec and GForth 0.7.0 ~65 sec to > run. bigForth et al actually do the work at run-time, because you told them to. Java may have noticed that the entire program is a no-op. GCC certainly can: $ cat opt.c int main (void) { int i; for (i = 0; i < 999999; i++); return 0; } $ gcc -O3 -S opt.c $ cat opt.s .file "opt.c" .section .text.startup,"ax",@progbits .p2align 4,,15 .globl main .type main, @function main: .LFB0: .cfi_startproc xorl %eax, %eax ret .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (GNU) 4.6.0 20110603 (Red Hat 4.6.0-10)" .section .note.GNU-stack,"",@progbits That's it. See any loops in that? If your programs need to do a lot of work that can be done at compile-time, or that reduce to nothing, of the two languages, only Forth lets you do this explicitly, and very naturally; you don't have to hope that an optimizer will notice. > a) Since BigForth is compiles to native code, why is its performance > similar to Retro, which is interpreted? Your _benchmark_ doesn't highlight any differences. A benchmark that gave native code more to do, might do better. A real program should do better. Although, I'm not equipped even to agree that Retro is interpreted. It's one of those defiantly non-ANS Forth-reminiscent languages. http://en.wikipedia.org/wiki/Software_rot#Example