]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/profiler/profiler-tests.factor
75ca5ede8c4060f9c6bcf63714d4d8ef2546880a
[factor.git] / basis / tools / profiler / profiler-tests.factor
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
5 [ t ] [
6     \ length counter>>
7     10 [ { } length drop ] times
8     \ length counter>> =
9 ] unit-test
10
11 [ ] [ [ 10 [ gc ] times ] profile ] unit-test
12
13 [ ] [ [ 1000 sleep ] profile ] unit-test 
14
15 [ ] [ profile. ] unit-test
16
17 [ ] [ vocabs-profile. ] unit-test
18
19 [ ] [ "kernel.private" vocab-profile. ] unit-test
20
21 [ ] [ \ + usage-profile. ] unit-test
22
23 : callback-test ( -- callback ) "void" { } "cdecl" [ ] alien-callback ;
24
25 : indirect-test ( callback -- ) "void" { } "cdecl" alien-indirect ;
26
27 : foobar ;
28
29 [
30     [ ] [ callback-test indirect-test ] unit-test
31     foobar
32 ] profile
33
34 [ 1 ] [ \ foobar counter>> ] unit-test
35
36 : fooblah { } [ ] each ;
37
38 : foobaz fooblah fooblah ;
39
40 [ foobaz ] profile
41
42 [ 1 ] [ \ foobaz counter>> ] unit-test
43
44 [ 2 ] [ \ fooblah counter>> ] unit-test
45
46 : recompile-while-profiling-test ( -- ) ;
47
48 [ ] [
49     [
50         333 [ recompile-while-profiling-test ] times
51         { recompile-while-profiling-test } compile
52         333 [ recompile-while-profiling-test ] times
53     ] profile
54 ] unit-test
55
56 [ 666 ] [ \ recompile-while-profiling-test counter>> ] unit-test