Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #50690
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Standard or Forth? |
| Date | 2016-09-05 08:10 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2016Sep5.101032@mips.complang.tuwien.ac.at> (permalink) |
| References | (7 earlier) <nq8882$3l2$1@gioia.aioe.org> <eeb99718-0245-48eb-98ea-0aa2cb0c98fe@googlegroups.com> <nqgfbv$ohl$1@dont-email.me> <241853cd-b15a-46eb-996b-6fb8a7265297@googlegroups.com> <nqh6kt$t1l$1@dont-email.me> |
Gerry Jackson <gerry@jackson9000.fsnet.co.uk> writes:
>On 04/09/2016 09:25, hughaguilar96@gmail.com wrote:
>> Why did you write your LexGen using Mini-OOF???
>
>Because it's small and elegant, providing much power with very little code.
>
>> It is obvious that Mini-OOF is typical Paysan code! This is his METHOD definer:
>>
>> : method ( m v -- m' v ) Create over , swap cell+ swap
>> DOES> ( ... o -- ... ) @ over @ + @ execute ;
>>
>> That is horribly inefficient! Any code that uses CREATE DOES> is going to be inefficient.
>
>So what. It's a bit slower, but if that isn't an issue it's a waste of
>time to worry about optimisation. I use a desktop PC that provides
>plenty of power so a few microseconds difference in execution time isn't
>a problem. Anyway that tool was developed about 10 years ago and you
>weren't around to educate me :)
>
>> My method calls are about 10 times more efficient under SwiftForth (SwiftForth is particularly inefficient with CREATE DOES> words) and about 3 times more efficient under VFX.
Let's see how much speedup we get from eliminating the memory access
caused by CREATE DOES> in LexGen, when using VFX. Here's the code:
0 [if]
synonym set-optimizer drop
: var ( m v size "<spaces>name" -- m v' )
create over , +
does> @ +
;
[else]
synonym set-optimizer set-compiler
synonym var +field
[then]
: opt-method ( xt -- )
>body @ postpone literal postpone over postpone @ postpone + postpone @ postpone execute ;
: method ( m v "<spaces>name" -- m' v )
create over , swap cell+ swap
['] opt-method set-optimizer
does>
@ over @ + @ execute
;
\ further down
: opt-class-var ( xt -- )
>body @ postpone literal postpone + ;
: class-var ( m v size "<spaces>name" -- m' v )
aligned 2>r
create dup ,
r> + r> ( -- m' v )
['] opt-class-var set-optimizer
does> ( class -- addr )
@ +
;
\ Class method - accessed via the class name, equivalent to
\ static methods
: opt-class-method ( xt -- )
>body @ postpone literal postpone over postpone + postpone @ postpone execute ;
: class-method ( m v "<spaces>name" -- m' v )
create
over , >r cell+ r>
['] opt-class-method set-optimizer
does> ( class -- ? )
@ over + @ execute
;
With the plain create-does> code, I get (9 runs, results in seconds
CPU time on a Core i7-6700K at 4GHz (no turbo)):
[1.884 1.892 1.916 1.920 1.920 1.920 1.924 1.924 1.928 ] lexex
With the optimized code, I get:
[1.896 1.896 1.900 1.900 1.904 1.908 1.908 1.908 1.908 ] lexex
A speedup by a whopping factor of 1.008 for the median result.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2016: http://www.euroforth.org/ef16/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Rosetta Code: Catamorphism "WJ" <w_a_x_man@yahoo.com> - 2016-08-24 15:27 +0000
Rosetta Code: Catamorphism Julian Fondren <julian.fondren@gmail.com> - 2016-08-24 12:43 -0700
Re: Rosetta Code: Catamorphism anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-25 09:53 +0000
Re: Rosetta Code: Catamorphism Julian Fondren <julian.fondren@gmail.com> - 2016-08-25 06:41 -0700
Re: Rosetta Code: Catamorphism Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-08-25 16:06 -0500
Re: Rosetta Code: Catamorphism foxaudioresearch@gmail.com - 2016-08-25 20:40 -0700
Rosetta Code ( was Re: Rosetta Code: Catamorphism) "HAA" <someone@microsoft.com> - 2016-08-29 12:06 +1000
Re: Rosetta Code ( was Re: Rosetta Code: Catamorphism) Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-08-29 01:41 -0500
Re: Rosetta Code: Catamorphism anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-27 10:01 +0000
Re: Rosetta Code: Catamorphism hughaguilar96@gmail.com - 2016-08-29 01:21 -0700
Re: Rosetta Code: Catamorphism hughaguilar96@gmail.com - 2016-08-29 01:36 -0700
Re: Rosetta Code: Catamorphism Julian Fondren <ayrnieu@gmail.com> - 2016-08-29 07:23 -0700
Re: Rosetta Code: Catamorphism anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-29 16:58 +0000
Re: Rosetta Code: Catamorphism peter.m.falth@gmail.com - 2016-08-29 13:15 -0700
Re: Rosetta Code: Catamorphism anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-29 20:53 +0000
Re: Rosetta Code: Catamorphism peter.m.falth@gmail.com - 2016-08-30 04:47 -0700
Re: Rosetta Code: Catamorphism anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-05 07:13 +0000
Re: Rosetta Code: Catamorphism "HAA" <someone@microsoft.com> - 2016-08-30 11:54 +1000
Re: Rosetta Code: Catamorphism "HAA" <someone@microsoft.com> - 2016-08-31 12:34 +1000
Re: Rosetta Code: Catamorphism "HAA" <someone@microsoft.com> - 2016-08-29 18:44 +1000
Re: Rosetta Code: Catamorphism hughaguilar96@gmail.com - 2016-09-01 23:47 -0700
Re: Rosetta Code: Catamorphism Coos Haak <htrofhc@gmail.com> - 2016-09-02 12:42 +0200
Re: Rosetta Code: Catamorphism anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-02 11:45 +0000
Re: Rosetta Code: Catamorphism Coos Haak <htrofhc@gmail.com> - 2016-09-02 15:01 +0200
Re: Rosetta Code: Catamorphism anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-02 16:04 +0000
Re: Rosetta Code: Catamorphism albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-02 16:23 +0200
Re: Rosetta Code: Catamorphism Bruce Axtens <bruce.axtens@gmail.com> - 2016-08-29 18:29 +0800
Re: Rosetta Code: Catamorphism Ron Aaron <rambamist@gmail.com> - 2016-08-29 13:41 +0300
Re: Rosetta Code: Catamorphism Bruce Axtens <bruce.axtens@gmail.com> - 2016-08-31 09:24 +0800
Standard or Forth? "HAA" <someone@microsoft.com> - 2016-09-01 13:45 +1000
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-02 21:54 -0700
Re: Standard or Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-04 07:35 +0100
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-04 00:41 -0700
Re: Standard or Forth? Julian Fondren <julian.fondren@gmail.com> - 2016-09-04 02:55 -0700
Re: Standard or Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-04 13:26 +0100
Re: Standard or Forth? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-04 13:59 +0000
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-04 23:09 -0700
Re: Standard or Forth? Ron Aaron <rambamist@gmail.com> - 2016-09-05 09:55 +0300
Re: Standard or Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-05 08:39 +0100
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-04 01:25 -0700
Re: Standard or Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-04 14:13 +0100
Re: Standard or Forth? Coos Haak <htrofhc@gmail.com> - 2016-09-04 23:16 +0200
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-04 22:33 -0700
Re: Standard or Forth? Ron Aaron <rambamist@gmail.com> - 2016-09-05 09:03 +0300
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-06 23:23 -0700
Re: Standard or Forth? Ron Aaron <rambamist@gmail.com> - 2016-09-07 10:14 +0300
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-07 01:01 -0700
Re: Standard or Forth? Ron Aaron <rambamist@gmail.com> - 2016-09-07 11:18 +0300
Re: Standard or Forth? Cecil Bayona <cbayona@cbayona.com> - 2016-09-07 08:47 -0500
Re: Standard or Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-05 09:20 +0100
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-05 02:21 -0700
Re: Standard or Forth? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-05 08:10 +0000
Re: Standard or Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-05 10:51 +0100
Re: Standard or Forth? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-03 08:05 +0200
Re: Standard or Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-03 03:00 -0500
Re: Standard or Forth? "HAA" <someone@microsoft.com> - 2016-09-03 22:48 +1000
Re: Standard or Forth? Alex <alex@rivadpm.com> - 2016-09-03 15:05 +0100
Re: Standard or Forth? Julian Fondren <julian.fondren@gmail.com> - 2016-09-03 07:46 -0700
Re: Standard or Forth? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-03 23:53 +0200
Re: Standard or Forth? stephen@mpeforth.com (Stephen Pelc) - 2016-09-03 22:37 +0000
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-03 21:17 -0700
Re: Standard or Forth? "HAA" <someone@microsoft.com> - 2016-09-05 02:35 +1000
Re: Standard or Forth? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-05 03:18 +0200
Re: Standard or Forth? "HAA" <someone@microsoft.com> - 2016-09-08 22:04 +1000
Re: Standard or Forth? Paul Rubin <no.email@nospam.invalid> - 2016-09-08 12:41 -0700
Re: Standard or Forth? "HAA" <someone@microsoft.com> - 2016-09-09 12:51 +1000
Re: Standard or Forth? Paul Rubin <no.email@nospam.invalid> - 2016-09-08 21:50 -0700
Re: Standard or Forth? "HAA" <someone@microsoft.com> - 2016-09-12 17:16 +1000
Re: Standard or Forth? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-12 16:59 +0000
Re: Standard or Forth? "HAA" <someone@microsoft.com> - 2016-09-15 13:38 +1000
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-08 23:33 -0700
Re: Standard or Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-05 08:41 +0100
Re: Standard or Forth? hughaguilar96@gmail.com - 2016-09-05 01:42 -0700
Re: Rosetta Code: Catamorphism albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-08-29 16:03 +0200
Re: Rosetta Code: Catamorphism anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-29 16:04 +0000
csiph-web