MessageTally.st
author Claus Gittinger <cg@exept.de>
Sat, 18 May 1996 19:07:36 +0200
changeset 262 0d84e23d2458
parent 261 2fb596a13d0c
child 263 4c3889934577
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
470788421600 Initial revision
claus
parents:
diff changeset
     1
"
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
     3
	      All Rights Reserved
0
470788421600 Initial revision
claus
parents:
diff changeset
     4
470788421600 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
470788421600 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
470788421600 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
470788421600 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
470788421600 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
470788421600 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
470788421600 Initial revision
claus
parents:
diff changeset
    11
"
470788421600 Initial revision
claus
parents:
diff changeset
    12
120
950e4628d657 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    13
Object subclass:#MessageTally
236
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    14
	instanceVariableNames:'process tree ntally theBlock spyInterval'
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    15
	classVariableNames:''
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    16
	poolDictionaries:''
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    17
	category:'System-Debugging-Support'
0
470788421600 Initial revision
claus
parents:
diff changeset
    18
!
470788421600 Initial revision
claus
parents:
diff changeset
    19
9
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    20
!MessageTally class methodsFor:'documentation'!
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    21
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    22
copyright
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    23
"
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    24
 COPYRIGHT (c) 1995 by Claus Gittinger
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    25
	      All Rights Reserved
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    26
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    27
 This software is furnished under a license and may be used
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    28
 only in accordance with the terms of that license and with the
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    30
 be provided or otherwise made available to, or used by, any
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    31
 other person.  No title to or ownership of the software is
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    32
 hereby transferred.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    33
"
9
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    34
!
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    35
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    36
documentation
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    37
"
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    38
    MessageTally allows profiling excution of a block; 
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    39
    statistic of method evaluation is output on Transcript.
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    40
    To get statistic, use 'MessageTally spyOn:aBlock'.
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    41
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    42
    By default, probing is done every 10ms (i.e. the execution of the block is 
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    43
    interrupted every 10ms, and the context chain analyzed).
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    44
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    45
    For better resolution, use smaller clock ticks (if your OperatingSystem
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    46
    supports it). Try 'spyDetailedOn:aBlock', which tries to measure things
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    47
    every 1ms. 
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    48
    (Notice, that some OS's do not provide this timer resolution,
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    49
     so measuring may be less accurate.)
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    50
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    51
    For good results, make certain that the measured block runs for some
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    52
    time (say 5 seconds) - add a timesRepeat-loop around it if required.
236
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    53
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    54
    [author:]
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    55
        Claus Gittinger
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    56
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    57
    [see also:]
261
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
    58
        CallChain ProfileTree
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
    59
        MessageTracer
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    60
"
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    61
!
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    62
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    63
examples
9
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    64
"
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    65
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    66
     MessageTally spyOn:[ #(6 5 4 3 2 1) cop sort ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    67
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    68
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    69
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    70
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    71
     MessageTally spyOn:[
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    72
        10000 timesRepeat:[ #(6 5 4 3 2 1) copy sort] 
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    73
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    74
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    75
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    76
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    77
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    78
     MessageTally spyOn:[
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    79
        100000 timesRepeat:[ #(6 5 4 3 2 1) copy sort] 
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    80
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    81
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    82
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    83
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    84
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    85
     MessageTally spyOn:[
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    86
        500000 timesRepeat:[#(6 5 4 3 2 1) copy sort] 
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    87
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    88
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    89
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    90
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    91
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    92
     MessageTally spyDetailedOn:[
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    93
        500000 timesRepeat:[#(6 5 4 3 2 1) copy sort] 
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    94
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    95
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    96
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    97
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    98
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    99
     Time millisecondsToRun:[
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   100
        500000 timesRepeat:[#(6 5 4 3 2 1) copy sort] 
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   101
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   102
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   103
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   104
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   105
                                                                        [exBegin]
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   106
     MessageTally spyOn:[SystemBrowser open ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   107
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   108
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   109
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   110
                                                                        [exBegin]
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   111
     MessageTally spyDetailedOn:[SystemBrowser open ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   112
                                                                        [exEnd]
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   113
"
9
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
   114
! !
0
470788421600 Initial revision
claus
parents:
diff changeset
   115
470788421600 Initial revision
claus
parents:
diff changeset
   116
!MessageTally class methodsFor:'instance creation'!
470788421600 Initial revision
claus
parents:
diff changeset
   117
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   118
spyDetailedOn:aBlock
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   119
    "evaluate aBlock and output time statistic on the Transcript.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   120
     Tick is 1ms."
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   121
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   122
    ^ self spyOn:aBlock interval:1
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   123
!
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   124
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   125
spyOn:aBlock
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   126
    "evaluate aBlock and output time statistic on the Transcript.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   127
     Tick is 10ms."
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   128
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   129
    ^ self spyOn:aBlock interval:10
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   130
!
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   131
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   132
spyOn:aBlock interval:ms
0
470788421600 Initial revision
claus
parents:
diff changeset
   133
    "evaluate aBlock and output time statistic on Transcript"
470788421600 Initial revision
claus
parents:
diff changeset
   134
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   135
    |runTime aTally nTally|
0
470788421600 Initial revision
claus
parents:
diff changeset
   136
470788421600 Initial revision
claus
parents:
diff changeset
   137
    aTally := self new.
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   138
    runTime := aTally spyOn:aBlock interval:ms.
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   139
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   140
    aTally tree isNil ifTrue:[
256
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   141
        Transcript cr.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   142
        Transcript showCR:'TALLY: No probes - execution time too short;'.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   143
        Transcript showCR:'TALLY: retry using: spyOn:[n timesRepeat:[...]]'.
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   144
    ] ifFalse:[
256
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   145
        "/ aTally tree inspect.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   146
        nTally := aTally nTally.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   147
        Transcript cr.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   148
        Transcript showCR:('total execution time: '
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   149
                           , runTime printString , ' ms '
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   150
                           , '(' , nTally printString , ' probes ;'
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   151
                           , ' error >= ' 
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   152
                           , (1000 // nTally / 10.0) printString
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   153
                           , '%)').
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   154
        Transcript cr.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   155
        aTally tree printOn:Transcript.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   156
        Transcript cr.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   157
        Transcript cr.
0
470788421600 Initial revision
claus
parents:
diff changeset
   158
256
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   159
        Transcript showCR:'leafs of calling tree:'.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   160
        Transcript cr.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   161
        aTally tree printLeafsOn:Transcript.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   162
        Transcript cr.
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   163
256
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   164
        "
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   165
        aTally statistics.
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   166
        "
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   167
    ].
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   168
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   169
    "
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   170
     MessageTally spyOn:[ #(6 5 4 3 2 1) sort ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   171
     MessageTally spyOn:[100 timesRepeat:[#(6 5 4 3 2 1) sort] ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   172
     MessageTally spyOn:[1000 timesRepeat:[#(6 5 4 3 2 1) sort] ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   173
     MessageTally spyOn:[10000 timesRepeat:[#(6 5 4 3 2 1) sort] ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   174
     MessageTally spyOn:[100000 timesRepeat:[#(6 5 4 3 2 1) sort] ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   175
     MessageTally spyOn:[500000 timesRepeat:[#(6 5 4 3 2 1) sort] ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   176
     MessageTally spyOn:[SystemBrowser open ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   177
     MessageTally spyDetailedOn:[SystemBrowser open ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   178
     Time millisecondsToRun:[500000 timesRepeat:[#(6 5 4 3 2 1) sort] ]
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   179
    "
256
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   180
da5bff51d133 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   181
    "Modified: 18.5.1996 / 15:42:44 / cg"
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   182
! !
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   183
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   184
!MessageTally methodsFor:'accessing'!
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   185
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   186
nTally 
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   187
    "return the number of accumulated probes"
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   188
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   189
    ^ ntally
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   190
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   191
    "Modified: 18.5.1996 / 18:47:47 / cg"
0
470788421600 Initial revision
claus
parents:
diff changeset
   192
!
470788421600 Initial revision
claus
parents:
diff changeset
   193
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   194
tree
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   195
    "return the accumulated calling tree"
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   196
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   197
    ^ tree
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   198
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   199
    "Modified: 18.5.1996 / 18:47:57 / cg"
0
470788421600 Initial revision
claus
parents:
diff changeset
   200
! !
470788421600 Initial revision
claus
parents:
diff changeset
   201
470788421600 Initial revision
claus
parents:
diff changeset
   202
!MessageTally methodsFor:'private'!
470788421600 Initial revision
claus
parents:
diff changeset
   203
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   204
execute
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   205
    "evaluate the target block"
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   206
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   207
    theBlock value
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   208
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   209
    "Modified: 18.5.1996 / 18:48:10 / cg"
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   210
! !
0
470788421600 Initial revision
claus
parents:
diff changeset
   211
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   212
!MessageTally methodsFor:'probes'!
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   213
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   214
count:aContext
262
0d84e23d2458 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
   215
    "{ Pragma: +optSpeed }"
0d84e23d2458 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
   216
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   217
    "entered whenever the probed block gets interrupted;
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   218
     look where it is, and remember in the calling tree"
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   219
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   220
    |con chain info atEnd sender home|
0
470788421600 Initial revision
claus
parents:
diff changeset
   221
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   222
    con := aContext.
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   223
    con isNil ifTrue:[^ self].
0
470788421600 Initial revision
claus
parents:
diff changeset
   224
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   225
    ntally := ntally + 1.
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   226
    "walk up above the interrupt context"
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   227
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   228
    [con receiver == Processor] whileTrue:[
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   229
        con := con sender
0
470788421600 Initial revision
claus
parents:
diff changeset
   230
    ].
470788421600 Initial revision
claus
parents:
diff changeset
   231
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   232
    "got it - collect info from contexts"
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   233
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   234
    "walk up"
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   235
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   236
    con isNil ifTrue:[^ self].
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   237
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   238
    atEnd := false.
0
470788421600 Initial revision
claus
parents:
diff changeset
   239
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   240
    [atEnd] whileFalse:[
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   241
        con isNil ifTrue:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   242
            atEnd := true
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   243
        ] ifFalse:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   244
            sender := con sender.
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   245
            sender isNil ifTrue:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   246
                atEnd := true
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   247
            ] ifFalse:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   248
                ((sender receiver == self) and:[sender selector == #execute]) ifTrue:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   249
                    atEnd := true
36
claus
parents: 24
diff changeset
   250
"/                ] ifFalse:[
claus
parents: 24
diff changeset
   251
"/                    (sender isMemberOf:BlockContext) ifTrue:[
claus
parents: 24
diff changeset
   252
"/                        sender sender selector == #execute ifTrue:[
claus
parents: 24
diff changeset
   253
"/                            atEnd := true
claus
parents: 24
diff changeset
   254
"/                        ]
claus
parents: 24
diff changeset
   255
"/                    ]
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   256
                ]
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   257
            ]
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   258
        ].
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   259
        atEnd ifFalse:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   260
            info := CallChain new.
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   261
            (con isMemberOf:BlockContext) ifTrue:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   262
                home := con methodHome.
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   263
                home isNil ifTrue:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   264
                    info receiver:UndefinedObject
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   265
                         selector:'optimized'
261
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   266
                            class:UndefinedObject
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   267
                          isBlock:true.
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   268
                ] ifFalse:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   269
                    info receiver:home receiver class
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   270
                         selector:home selector
261
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   271
                            class:con methodClass
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   272
                          isBlock:true.
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   273
                ].
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   274
            ] ifFalse:[
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   275
                info receiver:con receiver class
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   276
                     selector:con selector
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   277
                        class:con methodClass.
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   278
            ].
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   279
            info rest:chain.
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   280
            chain := info.
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   281
            con := sender
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   282
        ]
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   283
    ].
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   284
    "add chain to the tree"
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   285
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   286
    chain isNil ifTrue:[^ self].
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   287
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   288
    tree isNil ifTrue:[
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   289
        tree := ProfileTree new.
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   290
        tree receiver:MessageTally 
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   291
             selector:#execute 
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   292
                class:MessageTally .
0
470788421600 Initial revision
claus
parents:
diff changeset
   293
    ].
470788421600 Initial revision
claus
parents:
diff changeset
   294
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   295
    tree addChain:chain
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   296
261
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   297
    "Modified: 18.5.1996 / 18:53:31 / cg"
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   298
! !
0
470788421600 Initial revision
claus
parents:
diff changeset
   299
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   300
!MessageTally methodsFor:'setup'!
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   301
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   302
"spy on execution time"
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   303
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   304
    |startTime endTime running delay|
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   305
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   306
    theBlock := aBlock.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   307
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   308
    Processor activeProcess withPriority:23 do:[
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   309
	process := [
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   310
			[
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   311
			    self execute
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   312
			] valueNowOrOnUnwindDo:[
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   313
			    running := false.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   314
			    theBlock := nil.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   315
			]
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   316
		   ] newProcess.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   317
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   318
	Processor activeProcess withPriority:24 do:[
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   319
	    startTime := OperatingSystem getMillisecondTime.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   320
	    delay := (Delay forMilliseconds:ms).
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   321
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   322
	    ntally := 0.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   323
	    running := true.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   324
	    process resume.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   325
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   326
	    [running] whileTrue:[
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   327
		delay wait.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   328
		self count:process suspendedContext
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   329
	    ].
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   330
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   331
	    endTime := OperatingSystem getMillisecondTime.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   332
	].    
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   333
    ].    
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   334
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   335
    tree notNil ifTrue:[tree computePercentage:ntally].
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   336
    ^ endTime - startTime
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   337
! !
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   338
98
123d948aacd1 version at the end
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   339
!MessageTally class methodsFor:'documentation'!
123d948aacd1 version at the end
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   340
261
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   341
version
262
0d84e23d2458 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
   342
    ^ '$Header: /cvs/stx/stx/libbasic3/MessageTally.st,v 1.24 1996-05-18 17:07:36 cg Exp $'
98
123d948aacd1 version at the end
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   343
! !