From 6d63be4168672342eee67b6b919cabbb7dc5525c Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Thu, 10 Jun 2010 15:37:53 -0500
Subject: [PATCH] Check in benchmark.struct vocab

---
 extra/benchmark/struct/authors.txt   |  1 +
 extra/benchmark/struct/struct.factor | 31 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 extra/benchmark/struct/authors.txt
 create mode 100644 extra/benchmark/struct/struct.factor

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 )
+    \ benchmark-data <struct>
+        nano-count >>time
+        code-room >>code-room
+        data-room >>data-room ; inline
+
+: <benchmark-data-pair> ( start stop -- benchmark-data-pair )
+    \ benchmark-data-pair <struct>
+        swap >>stop
+        swap >>start ; inline
+
+: with-benchmarking ( ... quot -- ... benchmark-data-pair )
+    <benchmark-data>
+    [ call ] dip
+    <benchmark-data> <benchmark-data-pair> ; inline
+