-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
: 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 / ;
};
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];