/
AndreasSystemProfilerTest.class.st
102 lines (83 loc) · 2.33 KB
/
AndreasSystemProfilerTest.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"
SUnit tests for AndreasSystemProfiler
"
Class {
#name : #AndreasSystemProfilerTest,
#superclass : #TestCase,
#instVars : [
'tally'
],
#category : #'Tools-Test-Profilers'
}
{ #category : #running }
AndreasSystemProfilerTest >> setUp [
super setUp.
tally := QSystemTally new.
tally class: self class method: self class >> #testPrintingTally
"tally class: Object method: Object >> #printString."
]
{ #category : #'tests tally' }
AndreasSystemProfilerTest >> testFullPrintOn [
| stream |
stream := WriteStream on: String new.
tally fullPrintOn: stream tallyExact: false orThreshold: 0 time: 10.
self assert: stream contents equals: '**Tree**
**Leaves**
'
]
{ #category : #'tests tally' }
AndreasSystemProfilerTest >> testGetNewTab [
| tabs |
self assert: (tally getNewTabsFor: #()) equals: #().
self assert: (tally getNewTabsFor: #(' ')) equals: #(' ').
tabs := OrderedCollection new.
tabs add: '['.
(tally maxTabs + 1) timesRepeat: [ tabs add: ' ' ].
self assert: (tally getNewTabsFor: tabs) asArray equals: #('[' '[')
]
{ #category : #'tests tally' }
AndreasSystemProfilerTest >> testPrintingTally [
self assert: tally printString equals: 'AndreasSystemProfilerTest>>#testPrintingTally -- 0'
]
{ #category : #'tests tally' }
AndreasSystemProfilerTest >> testPrintingTallyUninitialized [
self assert: QSystemTally new printString equals: 'nil>>nil -- nil'
]
{ #category : #'tests profiler' }
AndreasSystemProfilerTest >> testSimple [
AndreasSystemProfiler new spyOn: [ 200 timesRepeat: [ 1.23 printString ]]
]
{ #category : #'tests profiler' }
AndreasSystemProfilerTest >> testSimpleReport [
AndreasSystemProfiler new report
]
{ #category : #'tests tally' }
AndreasSystemProfilerTest >> testTallyTreePrint [
| stream |
stream := WriteStream on: String new.
tally
treePrintOn: stream
tabs: #()
thisTab: nil
total: 50
totalTime: 100
tallyExact: true
orThreshold: 1.
"Nothing is printed since there is no tab"
self assert: stream contents isEmpty
]
{ #category : #'tests tally' }
AndreasSystemProfilerTest >> testTallyTreePrintWithTab [
| stream |
stream := WriteStream on: String new.
tally
treePrintOn: stream
tabs: #(' ')
thisTab: nil
total: 50
totalTime: 100
tallyExact: true
orThreshold: 1.
self assert: stream contents equals: ' 0 AndreasSystemProfilerTest testPrintingTally
'
]