]> gitweb.factorcode.org Git - factor.git/blob - extra/tools/time/struct/struct.factor
rename benchmark.struct to tools.time.struct since it is not a benchmark
[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 memory
4 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
12 STRUCT: benchmark-data-pair
13     { start benchmark-data }
14     { stop benchmark-data } ;
15
16 : <benchmark-data> ( -- benchmark-data )
17     \ benchmark-data <struct>
18         nano-count >>time
19         code-room >>code-room
20         data-room >>data-room ; inline
21
22 : <benchmark-data-pair> ( start stop -- benchmark-data-pair )
23     \ benchmark-data-pair <struct>
24         swap >>stop
25         swap >>start ; inline
26
27 : with-benchmarking ( ... quot -- ... benchmark-data-pair )
28     <benchmark-data>
29     [ call ] dip
30     <benchmark-data> <benchmark-data-pair> ; inline
31