Updating non-core libraries for monotonic? change
[factor/jcg.git] / basis / tools / profiler / profiler-tests.factor
blob197ace74d8e8a7ceefdf073dc2b45ab626f3786a
1 IN: tools.profiler.tests
2 USING: accessors tools.profiler tools.test kernel memory math
3 threads alien tools.profiler.private sequences compiler.units
4 words ;
6 [ t ] [
7     \ length counter>>
8     10 [ { } length drop ] times
9     \ length counter>> =
10 ] unit-test
12 [ ] [ [ 10 [ 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 ;
28 : foobar ;
31     [ ] [ callback-test indirect-test ] unit-test
32     foobar
33 ] profile
35 [ 1 ] [ \ foobar counter>> ] unit-test
37 : fooblah { } [ ] each ;
39 : foobaz fooblah fooblah ;
41 [ foobaz ] profile
43 [ 1 ] [ \ foobaz counter>> ] unit-test
45 [ 2 ] [ \ fooblah counter>> ] unit-test
47 : recompile-while-profiling-test ( -- ) ;
49 [ ] [
50     [
51         333 [ recompile-while-profiling-test ] times
52         { recompile-while-profiling-test } compile
53         333 [ recompile-while-profiling-test ] times
54     ] profile
55 ] unit-test
57 [ 666 ] [ \ recompile-while-profiling-test counter>> ] unit-test
59 [ ] [ [ [ ] compile-call ] profile ] unit-test
61 [ [ gensym execute ] profile ] [ T{ undefined } = ] must-fail-with