]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/profiler/profiler-tests.factor
Solution to Project Euler problem 65
[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 compiler.units
4 words ;
5
6 [ t ] [
7     \ length counter>>
8     10 [ { } length drop ] times
9     \ length counter>> =
10 ] unit-test
11
12 [ ] [ [ 10 [ gc ] times ] profile ] unit-test
13
14 [ ] [ [ 1000000 sleep ] profile ] unit-test 
15
16 [ ] [ profile. ] unit-test
17
18 [ ] [ vocabs-profile. ] unit-test
19
20 [ ] [ "kernel.private" vocab-profile. ] unit-test
21
22 [ ] [ \ + usage-profile. ] unit-test
23
24 : callback-test ( -- callback ) "void" { } "cdecl" [ ] alien-callback ;
25
26 : indirect-test ( callback -- ) "void" { } "cdecl" alien-indirect ;
27
28 : foobar ( -- ) ;
29
30 [
31     [ ] [ callback-test indirect-test ] unit-test
32     foobar
33 ] profile
34
35 [ 1 ] [ \ foobar counter>> ] unit-test
36
37 : fooblah ( -- ) { } [ ] like call( -- ) ;
38
39 : foobaz ( -- ) fooblah fooblah ;
40
41 [ foobaz ] profile
42
43 [ 1 ] [ \ foobaz counter>> ] unit-test
44
45 [ 2 ] [ \ fooblah counter>> ] unit-test
46
47 : recompile-while-profiling-test ( -- ) ;
48
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
56
57 [ 666 ] [ \ recompile-while-profiling-test counter>> ] unit-test
58
59 [ ] [ [ [ ] compile-call ] profile ] unit-test
60
61 [ [ gensym execute ] profile ] [ T{ undefined } = ] must-fail-with