factor/basis/tools/profiler/profiler-tests.factor

80 lines
1.8 KiB
Factor
Raw Normal View History

2008-06-30 04:57:00 -04:00
USING: accessors tools.profiler tools.test kernel memory math
2009-10-22 06:40:31 -04:00
threads alien alien.c-types tools.profiler.private sequences
compiler.test compiler.units words arrays ;
2009-10-22 06:40:31 -04:00
IN: tools.profiler.tests
2007-12-29 12:44:01 -05:00
[ t ] [
2008-06-30 04:57:00 -04:00
\ length counter>>
2007-12-29 12:44:01 -05:00
10 [ { } length drop ] times
2008-06-30 04:57:00 -04:00
\ length counter>> =
2007-12-29 12:44:01 -05:00
] unit-test
2007-09-20 18:09:08 -04:00
[ ] [ [ 3 [ gc ] times ] profile ] unit-test
2007-09-20 18:09:08 -04:00
[ ] [ [ 1000000 sleep ] profile ] unit-test
2007-09-20 18:09:08 -04:00
[ ] [ profile. ] unit-test
[ ] [ vocabs-profile. ] unit-test
[ ] [ "kernel.private" vocab-profile. ] unit-test
[ ] [ \ + usage-profile. ] unit-test
: callback-test ( -- callback ) void { } "cdecl" [ ] alien-callback ;
2007-09-20 18:09:08 -04:00
: indirect-test ( callback -- ) void { } "cdecl" alien-indirect ;
2007-09-20 18:09:08 -04:00
2009-03-19 21:02:43 -04:00
: foobar ( -- ) ;
2007-09-20 18:09:08 -04:00
[
[ ] [ callback-test indirect-test ] unit-test
foobar
] profile
2008-06-30 04:57:00 -04:00
[ 1 ] [ \ foobar counter>> ] unit-test
2007-12-29 12:44:01 -05:00
2009-04-22 08:05:00 -04:00
: fooblah ( -- ) { } [ ] like call( -- ) ;
2007-12-29 12:44:01 -05:00
2009-03-19 21:02:43 -04:00
: foobaz ( -- ) fooblah fooblah ;
2007-12-29 12:44:01 -05:00
[ foobaz ] profile
2008-06-30 04:57:00 -04:00
[ 1 ] [ \ foobaz counter>> ] unit-test
2007-12-29 12:44:01 -05:00
2008-06-30 04:57:00 -04:00
[ 2 ] [ \ fooblah counter>> ] unit-test
2008-07-05 23:19:16 -04:00
: recompile-while-profiling-test ( -- ) ;
[ ] [
[
333 [ recompile-while-profiling-test ] times
{ recompile-while-profiling-test } compile
333 [ recompile-while-profiling-test ] times
] profile
] unit-test
[ 666 ] [ \ recompile-while-profiling-test counter>> ] unit-test
[ ] [ [ [ ] compile-call ] profile ] unit-test
2010-02-01 15:41:13 -05:00
[ [ gensym execute ] profile ] [ undefined? ] must-fail-with
2009-11-14 00:00:50 -05:00
: crash-bug-1 ( -- x ) "hi" <uninterned-word> ;
: crash-bug-2 ( -- ) 100000 [ crash-bug-1 drop ] times ;
[ ] [ [ crash-bug-2 ] profile ] unit-test
[ 1 ] [
[
[ [ ] (( -- )) define-temp ] with-compilation-unit
dup execute( -- )
] profile
counter>>
] unit-test
! unwind_native_frames() would fail if profiling was enabled
! because the jit-profiling stub would clobber a parameter register
! on x86-64
[ [ -10 f <array> ] profile ] must-fail