]> gitweb.factorcode.org Git - factor.git/blob - extra/tools/time/struct/struct.factor
factor: trim using lists
[factor.git] / extra / tools / time / struct / struct.factor
1 ! Copyright (C) 2010 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types classes.struct kernel
4 tools.memory system vm ;
5 IN: tools.time.struct
6
7 STRUCT: benchmark-data
8     { time ulonglong }
9     { data-room data-heap-room }
10     { code-room mark-sweep-sizes }
11     { callback-room mark-sweep-sizes } ;
12
13 STRUCT: benchmark-data-pair
14     { start benchmark-data }
15     { stop benchmark-data } ;
16
17 : <benchmark-data> ( -- benchmark-data )
18     benchmark-data <struct>
19         nano-count >>time
20         data-room >>data-room
21         code-room >>code-room
22         callback-room >>callback-room ; inline
23
24 : <benchmark-data-pair> ( start stop -- benchmark-data-pair )
25     benchmark-data-pair <struct>
26         swap >>stop
27         swap >>start ; inline
28
29 : with-benchmarking ( ... quot -- ... benchmark-data-pair )
30     <benchmark-data>
31     [ call ] dip
32     <benchmark-data> <benchmark-data-pair> ; inline