diff --git a/extra/benchmark/struct/authors.txt b/extra/benchmark/struct/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/benchmark/struct/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/benchmark/struct/struct.factor b/extra/benchmark/struct/struct.factor new file mode 100644 index 0000000000..addc40ddba --- /dev/null +++ b/extra/benchmark/struct/struct.factor @@ -0,0 +1,31 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types classes.struct kernel memory +system vm ; +IN: benchmark.struct + +STRUCT: benchmark-data + { time ulonglong } + { data-room data-heap-room } + { code-room mark-sweep-sizes } ; + +STRUCT: benchmark-data-pair + { start benchmark-data } + { stop benchmark-data } ; + +: ( -- benchmark-data ) + \ benchmark-data + nano-count >>time + code-room >>code-room + data-room >>data-room ; inline + +: ( start stop -- benchmark-data-pair ) + \ benchmark-data-pair + swap >>stop + swap >>start ; inline + +: with-benchmarking ( ... quot -- ... benchmark-data-pair ) + + [ call ] dip + ; inline +