Skip to content

Commit

Permalink
tools.profiler.sampling: assert that profile-data is created.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Aug 13, 2020
1 parent 5eaaaf0 commit 995d717
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions basis/tools/profiler/sampling/sampling-tests.factor
@@ -1,6 +1,7 @@
USING: assocs byte-arrays calendar kernel kernel.private math memory
namespaces parser random sequences threads tools.profiler.sampling
tools.profiler.sampling.private tools.test ;
USING: assocs byte-arrays calendar kernel kernel.private math
memory namespaces parser random sequences threads
tools.profiler.sampling tools.profiler.sampling.private
tools.test ;
IN: tools.profiler.sampling.tests

! collect-tops: top is the last element in the array
Expand All @@ -13,12 +14,34 @@ IN: tools.profiler.sampling.tests
TUPLE: boom ;
{ } [ 10 [ [ ] profile ] times ] unit-test
[ 10 [ [ boom new throw ] profile ] times ] [ boom? ] must-fail-with
{ } [ 10 [ [ 100 [ 1000 random (byte-array) drop ] times gc ] profile ] times ] unit-test
{ } [ 10 [ [ 100 [ 1000 random (byte-array) drop ] times compact-gc ] profile ] times ] unit-test
{ } [ 2 [ [ 1 seconds sleep ] profile ] times ] unit-test

{ } [ [ 1,000,000 <iota> [ sq sq sq ] map drop ] profile flat profile. ] unit-test
{ } [ [ 1,000,000 <iota> [ sq sq sq ] map drop ] profile top-down profile. ] unit-test
{ t t t t t t t t t t } [
10 [
[
100 [ 1000 random (byte-array) >boolean t assert= ] times gc
] profile raw-profile-data get-global >boolean
] times
] unit-test

{ t t t t t t t t t t } [
10 [
[
100 [ 1000 random (byte-array) >boolean t assert= ] times compact-gc
] profile raw-profile-data get-global >boolean
] times
] unit-test

{ t t } [
2 [
[ 1 seconds sleep ] profile
raw-profile-data get-global >boolean
] times
] unit-test

{ t } [
[ 1,000,000 <iota> [ sq sq sq ] map >boolean t assert= ] profile
raw-profile-data get-global >boolean
] unit-test

f raw-profile-data set-global
gc
Expand Down

0 comments on commit 995d717

Please sign in to comment.