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
|
2010-02-04 20:29:45 -05:00
|
|
|
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
|
|
|
|
2010-02-04 20:29:45 -05:00
|
|
|
[ ] [ [ 3 [ gc ] times ] profile ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-11-19 02:50:05 -05: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
|
|
|
|
|
|
2009-10-21 22:10:11 -04:00
|
|
|
: callback-test ( -- callback ) void { } "cdecl" [ ] alien-callback ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-10-21 22:10:11 -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
|
2008-11-12 00:07:40 -05:00
|
|
|
|
|
|
|
|
[ ] [ [ [ ] compile-call ] profile ] unit-test
|
|
|
|
|
|
2010-02-01 15:41:13 -05:00
|
|
|
[ [ gensym execute ] profile ] [ undefined? ] must-fail-with
|
2009-09-24 05:31:11 -04:00
|
|
|
|
2009-11-14 00:00:50 -05:00
|
|
|
: crash-bug-1 ( -- x ) "hi" <uninterned-word> ;
|
2009-09-24 05:31:11 -04:00
|
|
|
: crash-bug-2 ( -- ) 100000 [ crash-bug-1 drop ] times ;
|
|
|
|
|
|
|
|
|
|
[ ] [ [ crash-bug-2 ] profile ] unit-test
|
2009-11-19 02:49:26 -05:00
|
|
|
|
|
|
|
|
[ 1 ] [
|
|
|
|
|
[
|
|
|
|
|
[ [ ] (( -- )) define-temp ] with-compilation-unit
|
|
|
|
|
dup execute( -- )
|
|
|
|
|
] profile
|
|
|
|
|
counter>>
|
|
|
|
|
] unit-test
|
2010-02-04 20:29:45 -05:00
|
|
|
|
|
|
|
|
! 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
|