From 7378ba77172b8073ac0707a2d3ada2ffebc74c4c Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Wed, 2 Nov 2011 17:01:43 -0700
Subject: [PATCH] Unbreakify the new profiler, add a couple of unit tests to
 demonstrate displaying output.

---
 basis/tools/profiler/sampling/sampling-tests.factor | 6 +++++-
 basis/tools/profiler/sampling/sampling.factor       | 5 ++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/basis/tools/profiler/sampling/sampling-tests.factor b/basis/tools/profiler/sampling/sampling-tests.factor
index 615cf97018..22e2d17bb6 100644
--- a/basis/tools/profiler/sampling/sampling-tests.factor
+++ b/basis/tools/profiler/sampling/sampling-tests.factor
@@ -1,6 +1,6 @@
 USING: byte-arrays calendar kernel math memory namespaces
 random threads tools.profiler.sampling
-tools.profiler.sampling.private tools.test ;
+tools.profiler.sampling.private tools.test sequences ;
 IN: tools.profiler.sampling.tests
 
 ! Make sure the profiler doesn't blow up the VM
@@ -11,6 +11,10 @@ TUPLE: boom ;
 { } [ 10 [ [ 100 [ 1000 random (byte-array) drop ] times compact-gc ] profile ] times ] unit-test
 { } [ 2 [ [ 1 seconds sleep ] profile ] times ] unit-test
 
+
+[ ] [ [ 10 iota [ sq ] map ] profile flat profile. ] unit-test
+[ ] [ [ 10 iota [ sq ] map ] profile top-down profile. ] unit-test
+
 (clear-samples)
 f raw-profile-data set-global
 gc
diff --git a/basis/tools/profiler/sampling/sampling.factor b/basis/tools/profiler/sampling/sampling.factor
index 9a0fc783c6..ab23f5be85 100644
--- a/basis/tools/profiler/sampling/sampling.factor
+++ b/basis/tools/profiler/sampling/sampling.factor
@@ -24,9 +24,8 @@ CONSTANT: ignore-words
 
 : profile ( quot -- )
     samples-per-second get-global profiling
-    [ 0 profiling ] [
-        (get-samples) raw-profile-data set-global
-    ] cleanup ; inline
+    [ 0 profiling (get-samples) raw-profile-data set-global ]
+    [ ] cleanup ; inline
 
 : total-sample-count ( sample -- count ) 0 swap nth ;
 : gc-sample-count ( sample -- count ) 1 swap nth ;