1 USING: accessors tools.counting-profiler tools.test kernel memory math
2 threads alien alien.c-types tools.counting-profiler.private sequences
3 compiler.test compiler.units words arrays ;
4 IN: tools.counting-profiler.tests
8 10 [ { } length drop ] times
12 [ ] [ [ 3 [ gc ] times ] profile ] unit-test
14 [ ] [ [ 1000000 sleep ] profile ] unit-test
16 [ ] [ profile. ] unit-test
18 [ ] [ vocabs-profile. ] unit-test
20 [ ] [ "kernel.private" vocab-profile. ] unit-test
22 [ ] [ \ + usage-profile. ] unit-test
24 : callback-test ( -- callback ) void { } cdecl [ ] alien-callback ;
26 : indirect-test ( callback -- ) void { } cdecl alien-indirect ;
31 [ ] [ callback-test indirect-test ] unit-test
35 [ 1 ] [ \ foobar counter>> ] unit-test
37 : fooblah ( -- ) { } [ ] like call( -- ) ;
39 : foobaz ( -- ) fooblah fooblah ;
43 [ 1 ] [ \ foobaz counter>> ] unit-test
45 [ 2 ] [ \ fooblah counter>> ] unit-test
47 : recompile-while-profiling-test ( -- ) ;
51 333 [ recompile-while-profiling-test ] times
52 { recompile-while-profiling-test } compile
53 333 [ recompile-while-profiling-test ] times
57 [ 666 ] [ \ recompile-while-profiling-test counter>> ] unit-test
59 [ ] [ [ [ ] compile-call ] profile ] unit-test
61 [ [ gensym execute ] profile ] [ undefined? ] must-fail-with
63 : crash-bug-1 ( -- x ) "hi" <uninterned-word> ;
64 : crash-bug-2 ( -- ) 100000 [ crash-bug-1 drop ] times ;
66 [ ] [ [ crash-bug-2 ] profile ] unit-test
70 [ [ ] ( -- ) define-temp ] with-compilation-unit
76 ! unwind_native_frames() would fail if profiling was enabled
77 ! because the jit-profiling stub would clobber a parameter register
79 [ [ -10 f <array> ] profile ] must-fail