Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #133835
| From | zbigniew2011@gmail.com (LIT) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: OOS approach revisited |
| Date | 2025-06-26 17:27 +0000 |
| Organization | novaBBS |
| Message-ID | <c9158c200102c2e508f8ef11deecdc27@www.novabbs.com> (permalink) |
| References | <fdbeb48de8ceb748d44c67dc3981a566@www.novabbs.com> <84d259e0f1d6210d84c7840af5d51f4ebdd71ed4@i2pn2.org> |
> The saving come from rolling @ @ + ! into a single very specialized
> function. But what about the loading of X Y and retrieving of Z which
> are unavoidable in practice? Should that not be included in the test?
Let's find out then:
1 VARIABLE X
2 VARIABLE Y
3 VARIABLE Z
: TEST1 1000 0 DO 10000 0 DO
I DUP X ! Y ! X @ Y @ + Z ! Z @ DROP
LOOP LOOP ;
: TEST2 1000 0 DO 10000 0 DO
I DUP X ! Y ! X Y Z +> Z @ DROP
LOOP LOOP ;
TICKS TEST1 TICKS 2SWAP DMINUS D+ D. 252 ok
TICKS TEST2 TICKS 2SWAP DMINUS D+ D. 202 ok
: TEST1 1000 0 DO 10000 0 DO
I DUP X ! Y ! 1 X +! 1 Y +! X @ Y @ + Z ! Z @ DROP
LOOP LOOP ;
: TEST2 1000 0 DO 10000 0 DO
I DUP X ! Y ! X ++ Y ++ X Y Z +> Z @ DROP
LOOP LOOP ;
TICKS TEST1 TICKS 2SWAP DMINUS D+ D. 346 ok
TICKS TEST2 TICKS 2SWAP DMINUS D+ D. 258 ok
The difference is smaller - still it's significant.
Another test - using the "drawing a box" example
from "Thinking Forth" (and "simulated" LINE word):
0 VARIABLE TOP
0 VARIABLE LEFT
0 VARIABLE BOTTOM
0 VARIABLE RIGHT
: LINE 2DROP 2DROP ;
: BOX1 ( x1 y1 x2 y2) BOTTOM ! RIGHT ! TOP ! LEFT !
LEFT @ TOP @ RIGHT @ TOP @ LINE
RIGHT @ TOP @ RIGHT @ BOTTOM @ LINE
RIGHT @ BOTTOM @ LEFT @ BOTTOM @ LINE
LEFT @ BOTTOM @ LEFT @ TOP @ LINE ;
: BOX2 ( x1 y1 x2 y2) BOTTOM ! RIGHT ! TOP ! LEFT !
LEFT TOP RIGHT TOP LINE
RIGHT TOP RIGHT BOTTOM LINE
RIGHT BOTTOM LEFT BOTTOM LINE
LEFT BOTTOM LEFT TOP LINE ;
: TEST1 1000 0 DO 10000 0 DO I DUP 2DUP BOX1 LOOP LOOP ;
: TEST2 1000 0 DO 10000 0 DO I DUP 2DUP BOX2 LOOP LOOP ;
TICKS TEST1 TICKS 2SWAP DMINUS D+ D. 890 ok
TICKS TEST2 TICKS 2SWAP DMINUS D+ D. 653 ok
The difference is even more significant in case
of multiplication:
1 VARIABLE X
2 VARIABLE Y
3 VARIABLE Z
: TEST1 1000 0 DO 10000 0 DO
I DUP X ! Y ! X @ Y @ * Z ! Z @ DROP
LOOP LOOP ;
: TEST2 1000 0 DO 10000 0 DO
I DUP X ! Y ! X Y Z *> Z @ DROP
LOOP LOOP ;
TICKS TEST1 TICKS 2SWAP DMINUS D+ D. 658 ok
TICKS TEST2 TICKS 2SWAP DMINUS D+ D. 200 ok
But this time better implementation has also
its impact; fig-Forth's '*' is inefficient,
and I coded '*>' of course directly in ML,
simply using IMUL.
--
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
OOS approach revisited zbigniew2011@gmail.com (LIT) - 2025-06-23 05:09 +0000
Re: OOS approach revisited dxf <dxforth@gmail.com> - 2025-06-24 23:28 +1000
Re: OOS approach revisited zbigniew2011@gmail.com (LIT) - 2025-06-26 17:27 +0000
Re: OOS approach revisited minforth@gmx.net (minforth) - 2025-06-27 02:16 +0000
Re: OOS approach revisited dxf <dxforth@gmail.com> - 2025-06-27 17:29 +1000
Re: OOS approach revisited minforth <minforth@gmx.net> - 2025-06-27 11:49 +0200
Re: OOS approach revisited zbigniew2011@gmail.com (LIT) - 2025-06-27 16:55 +0000
Re: OOS approach revisited albert@spenarnc.xs4all.nl - 2025-06-27 20:15 +0200
Re: OOS approach revisited minforth <minforth@gmx.net> - 2025-06-27 22:35 +0200
Re: OOS approach revisited albert@spenarnc.xs4all.nl - 2025-06-28 11:34 +0200
Re: OOS approach revisited Stephen Pelc <stephen@vfxforth.com> - 2025-06-28 09:37 +0000
Re: OOS approach revisited dxf <dxforth@gmail.com> - 2025-06-28 12:03 +1000
LOOP (was: OOS approach revisited) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-28 10:23 +0000
Re: LOOP (was: OOS approach revisited) albert@spenarnc.xs4all.nl - 2025-06-28 14:26 +0200
Re: LOOP dxf <dxforth@gmail.com> - 2025-06-28 22:41 +1000
Re: LOOP sean@conman.org - 2025-06-28 20:04 +0000
Re: LOOP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-28 21:01 +0000
Re: LOOP minforth@gmx.net (minforth) - 2025-07-03 19:33 +0000
Re: LOOP Gerry Jackson <do-not-use@swldwa.uk> - 2025-07-07 07:54 +0100
Re: LOOP minforth <minforth@gmx.net> - 2025-07-07 10:46 +0200
Re: LOOP dxf <dxforth@gmail.com> - 2025-06-29 13:04 +1000
Re: LOOP (was: OOS approach revisited) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-28 16:04 +0000
DO..LOOP and stack shuffling (was: OOS approach revisited) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-28 17:46 +0000
Re: DO..LOOP and stack shuffling Hans Bezemer <the.beez.speaks@gmail.com> - 2025-07-01 13:53 +0200
Re: DO..LOOP and stack shuffling dxf <dxforth@gmail.com> - 2025-07-03 13:59 +1000
Re: DO..LOOP and stack shuffling anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-07-03 07:50 +0000
Re: OOS approach revisited Hans Bezemer <the.beez.speaks@gmail.com> - 2025-06-30 15:43 +0200
Re: OOS approach revisited dxf <dxforth@gmail.com> - 2025-06-27 13:39 +1000
csiph-web