]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: remove the reversing from sampling profiler callstack collection #452
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 11 Oct 2016 08:45:09 +0000 (10:45 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Wed, 12 Oct 2016 23:34:55 +0000 (01:34 +0200)
basis/tools/profiler/sampling/sampling-tests.factor
basis/tools/profiler/sampling/sampling.factor
vm/sampling_profiler.cpp

index f2beb18d0e2f8aeacae8e4145eda55bc92c5aae1..06c1ff9f18100be7ddb161437ca348a53b095d4d 100644 (file)
@@ -1,8 +1,14 @@
-USING: byte-arrays calendar kernel math memory namespaces parser
-random sequences threads tools.profiler.sampling
+USING: assocs byte-arrays calendar kernel math memory namespaces
+parser random sequences threads tools.profiler.sampling
 tools.profiler.sampling.private tools.test ;
 IN: tools.profiler.sampling.tests
 
+! collect-tops: top is the last element in the array
+{ 5 } [
+    { { 1 2 3 4 5 6 { 3 4 5 } } } 1 2 collect-tops
+    keys first
+] unit-test
+
 ! Make sure the profiler doesn't blow up the VM
 TUPLE: boom ;
 { } [ 10 [ [ ] profile ] times ] unit-test
index bc8ac7a744dffaca42f36742172d7569f46979d5..6e07541deb03e184d2a6a25eb027e89ba083ee98 100644 (file)
@@ -41,7 +41,7 @@ PRIVATE>
 : sample-thread ( sample -- thread ) 5 swap nth ;
 : sample-callstack ( sample -- array ) 6 swap nth ;
 : unclip-callstack ( sample -- sample' callstack-top )
-    clone 6 over [ unclip swap ] change-nth ;
+    clone 6 over [ unclip-last swap ] change-nth ;
 
 : samples>time ( samples -- seconds )
     samples-per-second get-global / ;
index 97141813d12362a0ed30920f4e17316a9595f03e..f49d4b98cb709a7184613e823371aa74be2ff0c7 100644 (file)
@@ -49,7 +49,6 @@ void factor_vm::record_sample(bool prolog_p) {
   };
   iterate_callstack(ctx, recorder);
   cell end = sample_callstacks.size();
-  std::reverse(sample_callstacks.begin() + begin, sample_callstacks.end());
 
   // Add the sample.
   cell thread = special_objects[OBJ_CURRENT_THREAD];