1 USING: assocs byte-arrays calendar kernel kernel.private math memory
2 namespaces parser random sequences threads tools.profiler.sampling
3 tools.profiler.sampling.private tools.test ;
4 IN: tools.profiler.sampling.tests
6 ! collect-tops: top is the last element in the array
8 { { 1 2 3 4 5 6 { 3 4 5 } } } 1 2 collect-tops
12 ! Make sure the profiler doesn't blow up the VM
14 { } [ 10 [ [ ] profile ] times ] unit-test
15 [ 10 [ [ boom new throw ] profile ] times ] [ boom? ] must-fail-with
16 { } [ 10 [ [ 100 [ 1000 random (byte-array) drop ] times gc ] profile ] times ] unit-test
17 { } [ 10 [ [ 100 [ 1000 random (byte-array) drop ] times compact-gc ] profile ] times ] unit-test
18 { } [ 2 [ [ 1 seconds sleep ] profile ] times ] unit-test
20 { } [ [ 300,000 iota [ sq sq sq ] map drop ] profile flat profile. ] unit-test
21 { } [ [ 300,000 iota [ sq sq sq ] map drop ] profile top-down profile. ] unit-test
23 f raw-profile-data set-global
27 ! Seed the samples data
28 [ "resource:basis/tools/memory/memory.factor" run-file ] profile
29 (get-samples) length 0 >
30 OBJ-SAMPLE-CALLSTACKS special-object first 0 >
34 ! On x86.64, [ ] profile doesn't generate any samples at all
35 ! because it runs so quickly. On x86.32, one spurious sample is
36 ! sometimes generated for some unknown reason.
37 gc [ ] profile (get-samples) length 1 <=