Add inline declarations to binary-trees benchmark for ~8% performance gain

db4
Slava Pestov 2008-09-03 03:39:49 -05:00
parent ac97c1e14c
commit 5ae4165570
1 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ C: <tree-node> tree-node
[ >r 2 * r> bottom-up-tree ] 2tri [ >r 2 * r> bottom-up-tree ] 2tri
] [ ] [
drop f f drop f f
] if <tree-node> ; ] if <tree-node> ; inline recursive
GENERIC: item-check ( node -- n ) GENERIC: item-check ( node -- n )
@ -28,7 +28,7 @@ M: f item-check drop 0 ;
: stretch-tree ( max-depth -- ) : stretch-tree ( max-depth -- )
1 + 0 over bottom-up-tree item-check 1 + 0 over bottom-up-tree item-check
[ "stretch tree of depth " write pprint ] [ "stretch tree of depth " write pprint ]
[ "\t check: " write . ] bi* ; [ "\t check: " write . ] bi* ; inline
:: long-lived-tree ( max-depth -- ) :: long-lived-tree ( max-depth -- )
0 max-depth bottom-up-tree 0 max-depth bottom-up-tree
@ -46,10 +46,10 @@ M: f item-check drop 0 ;
] each ] each
"long lived tree of depth " write max-depth pprint "long lived tree of depth " write max-depth pprint
"\t check: " write item-check . ; "\t check: " write item-check . ; inline
: binary-trees ( n -- ) : binary-trees ( n -- )
min-depth 2 + max [ stretch-tree ] [ long-lived-tree ] bi ; min-depth 2 + max [ stretch-tree ] [ long-lived-tree ] bi ; inline
: binary-trees-main ( -- ) : binary-trees-main ( -- )
16 binary-trees ; 16 binary-trees ;