MessageTally.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 29 Jan 2012 12:51:41 +0000
branchjv
changeset 3011 1997ff6e7e55
parent 2281 859191db074f
child 3012 4f40b8304d54
permissions -rw-r--r--
trunk branched into /branches/jv
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
"
957
54dade11e57f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
    12
"{ Package: 'stx:libbasic3' }"
54dade11e57f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
    13
120
950e4628d657 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    14
Object subclass:#MessageTally
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
    15
	instanceVariableNames:'tree probes ntally theBlock spyInterval executing startTime
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
    16
		endTime'
236
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    17
	classVariableNames:''
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    18
	poolDictionaries:''
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    19
	category:'System-Debugging-Support'
0
470788421600 Initial revision
claus
parents:
diff changeset
    20
!
470788421600 Initial revision
claus
parents:
diff changeset
    21
9
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    22
!MessageTally class methodsFor:'documentation'!
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    23
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    24
copyright
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    25
"
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    27
	      All Rights Reserved
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    28
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    29
 This software is furnished under a license and may be used
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    30
 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
    31
 inclusion of the above copyright notice.   This software may not
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    32
 be provided or otherwise made available to, or used by, any
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    33
 other person.  No title to or ownership of the software is
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    34
 hereby transferred.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
    35
"
9
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    36
!
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    37
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    38
documentation
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    39
"
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    40
    MessageTally allows profiling excution of a block; 
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    41
    statistic of method evaluation is output on Transcript.
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    42
    To get statistic, use 'MessageTally spyOn:aBlock'.
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    43
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    44
    By default, probing is done every 10ms (i.e. the execution of the block is 
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    45
    interrupted every 10ms, and the context chain analyzed).
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    46
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    47
    For better resolution, use smaller clock ticks (if your OperatingSystem
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    48
    supports it). Try 'spyDetailedOn:aBlock', which tries to measure things
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    49
    every 1ms. 
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    50
    (Notice, that some OS's do not provide this timer resolution,
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    51
     so measuring may be less accurate.)
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    52
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    53
    For good results, make certain that the measured block runs for some
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    54
    time (say 5 seconds) - add a timesRepeat-loop around it if required.
236
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    55
561
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    56
    The displayed information is:
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    57
        - the calling tree augmented with total and leaf times.
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    58
          the leaf time is the time spent in the method itself;
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    59
          the total time is the time spent in the method and all of its called
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    60
          methods.
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    61
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    62
        - the leaf methods by receiver
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    63
          this lists the leaf nodes only, sorted by time spent there.
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    64
          Here, method invocations for different receiver types are
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    65
          listed separately.
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    66
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    67
        - the leaf methods
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    68
          this lists the leaf nodes only, sorted by time spent there.
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    69
          Here, method invocations for different receiver types are
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    70
          summed up separately.
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    71
594
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    72
    The last list (leaf methods) is propably the most interesting;
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
    73
    if you are only interested in that (or the calling hierarchy is too
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    74
    deep for the list to be useful or the amount of data to be handled
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    75
    correctly), use a leaf-spy with:
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    76
        MessageTally spyLeafOn:aBlock
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    77
    This only accumulates statistics about methods where the cpu time
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    78
    is actually spent (not collecing hierarchy information).
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    79
561
4c7d7e58cc8a better printOut & comment.
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
    80
236
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    81
    [author:]
7f570e0a0a75 documentation
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
    82
        Claus Gittinger
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    83
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    84
    [see also:]
261
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
    85
        CallChain ProfileTree
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
    86
        MessageTracer
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    87
"
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    88
!
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    89
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
    90
examples
9
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
    91
"
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    92
  the block must execute for a while;
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    93
  otherwise, no probes (and therefore no statistics) can
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
    94
  be gathered:
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    95
                                                                        [exBegin]
264
4cd9760b6de6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    96
     MessageTally spyOn:[ #(6 5 4 3 2 1) sort ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    97
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    98
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
    99
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   100
  if required, execute the block in a loop;
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   101
  however, for the example below, a larger repeat count
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   102
  is required, for a reasonable measurement:
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   103
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   104
     MessageTally spyOn:[
264
4cd9760b6de6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   105
        10000 timesRepeat:[ #(6 5 4 3 2 1) sort] 
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   106
     ]
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
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   110
  thats better:
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   111
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   112
     MessageTally spyOn:[
264
4cd9760b6de6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   113
        100000 timesRepeat:[ #(6 5 4 3 2 1) sort] 
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   114
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   115
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   116
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   117
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   118
  thats much better
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   119
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   120
     MessageTally spyOn:[
264
4cd9760b6de6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   121
        500000 timesRepeat:[#(6 5 4 3 2 1) sort] 
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   122
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   123
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   124
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   125
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   126
  a smaller probing tick also helps:
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   127
                                                                        [exBegin]
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   128
     MessageTally spyDetailedOn:[
570
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   129
        500000 timesRepeat:[(10 to:1 by:-1) asArray reverse] 
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   130
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   131
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   132
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   133
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   134
  as usual, measurements add some extra overhead;
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   135
  compare the above time to the time given by:
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   136
                                                                        [exBegin]
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   137
     Transcript showCR:(
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   138
         Time millisecondsToRun:[
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   139
            500000 timesRepeat:[#(6 5 4 3 2 1) sort] 
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   140
         ]
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   141
     )
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   142
                                                                        [exEnd]
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   143
  probing the leafs only may help to reduce the overhead
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   144
  a bit:
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   145
                                                                        [exBegin]
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   146
     MessageTally spyLeafDetailedOn:[
264
4cd9760b6de6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   147
        500000 timesRepeat:[#(6 5 4 3 2 1) sort] 
259
eb2d1a3e3b52 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
   148
     ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   149
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   150
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   151
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   152
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   153
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   154
                                                                        [exBegin]
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   155
     MessageTally spyOn:[SystemBrowser open ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   156
                                                                        [exEnd]
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   157
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   158
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   159
                                                                        [exBegin]
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   160
     MessageTally spyDetailedOn:[SystemBrowser open ]
244
42acac0f7b8c examples
Claus Gittinger <cg@exept.de>
parents: 236
diff changeset
   161
                                                                        [exEnd]
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   162
"
9
f5b6ab00bdf6 *** empty log message ***
claus
parents: 5
diff changeset
   163
! !
0
470788421600 Initial revision
claus
parents:
diff changeset
   164
1280
f08fe6cf6348 category
Claus Gittinger <cg@exept.de>
parents: 1152
diff changeset
   165
!MessageTally class methodsFor:'spying-private'!
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   166
570
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   167
spyLeafOn:aBlock interval:ms to:outStream
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   168
    "evaluate aBlock and output leaf method statistics on outStream"
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   169
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   170
    |aTally|
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   171
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   172
    aTally := self new.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   173
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   174
    [
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   175
        [
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   176
            aTally spyLeafOn:aBlock interval:ms.
1152
b1f95f16a0a4 Use #ifCurtailed: instead of #valueOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents: 1139
diff changeset
   177
        ] ifCurtailed:[
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   178
            outStream nextPutLine:'TALLY: block returned'.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   179
        ]
1139
56861678ff27 #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   180
    ] ensure:[
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   181
        aTally printLeafStatisticOn:outStream
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   182
    ].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   183
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   184
    "Modified: 22.3.1997 / 16:50:47 / cg"
88
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
570
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   187
spyOn:aBlock interval:ms to:outStream
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   188
    "evaluate aBlock and output full statistics on outstream"
0
470788421600 Initial revision
claus
parents:
diff changeset
   189
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   190
    |aTally retVal|
0
470788421600 Initial revision
claus
parents:
diff changeset
   191
470788421600 Initial revision
claus
parents:
diff changeset
   192
    aTally := self new.
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   193
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   194
    [
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   195
        [
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   196
            retVal := aTally spyOn:aBlock interval:ms.
1152
b1f95f16a0a4 Use #ifCurtailed: instead of #valueOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents: 1139
diff changeset
   197
        ] ifCurtailed:[
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   198
            outStream nextPutLine:'TALLY: block returned'.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   199
        ]
1139
56861678ff27 #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   200
    ] ensure:[
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   201
        aTally printFullStatisticOn:outStream
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   202
    ].
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   203
    ^ retVal
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   204
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   205
    "Modified: 22.3.1997 / 16:54:36 / cg"
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   206
! !
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   207
1280
f08fe6cf6348 category
Claus Gittinger <cg@exept.de>
parents: 1152
diff changeset
   208
!MessageTally class methodsFor:'spying-public interface'!
570
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   209
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   210
spyDetailedOn:aBlock
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   211
    "evaluate aBlock and output full statistics on the Transcript.
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   212
     The Tick is 1ms for more detailed measurement.
1376
7feb7011cdc2 Fix typos
Stefan Vogel <sv@exept.de>
parents: 1280
diff changeset
   213
     Notice: not all architectures support such a small timer interval."
570
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   214
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   215
    ^ self spyOn:aBlock interval:1 to:Transcript
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   216
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   217
    "Modified: 22.3.1997 / 16:26:39 / cg"
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   218
!
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   219
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   220
spyLeafDetailedOn:aBlock
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   221
    "evaluate aBlock and output leaf method statistics on the Transcript.
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   222
     The Tick is 1ms for more detailed measurement.
1376
7feb7011cdc2 Fix typos
Stefan Vogel <sv@exept.de>
parents: 1280
diff changeset
   223
     Notice: not all architectures support such a small timer interval."
570
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   224
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   225
    ^ self spyLeafOn:aBlock interval:1 to:Transcript
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   226
570
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   227
    "Created: 20.3.1997 / 20:41:53 / cg"
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   228
    "Modified: 22.3.1997 / 16:26:47 / cg"
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   229
!
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   230
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   231
spyLeafOn:aBlock
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   232
    "evaluate aBlock and output leaf method statistics on the Transcript.
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   233
     The Tick is 10ms for less detailed measurements."
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   234
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   235
    ^ self spyLeafOn:aBlock interval:10 to:Transcript
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   236
570
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   237
    "Created: 20.3.1997 / 20:41:40 / cg"
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   238
    "Modified: 22.3.1997 / 16:26:49 / cg"
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   239
!
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   240
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   241
spyOn:aBlock
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   242
    "evaluate aBlock and output full statistics on the Transcript.
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   243
     The Tick is 10ms for less detailed measurements."
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   244
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   245
    ^ self spyOn:aBlock interval:10 to:Transcript
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   246
9c3efb856ee6 allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   247
    "Modified: 22.3.1997 / 16:26:51 / cg"
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   248
! !
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   249
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   250
!MessageTally methodsFor:'accessing'!
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   251
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   252
endTime
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   253
    "return the endTime of the run"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   254
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   255
    ^ endTime
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   256
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   257
    "Modified: 18.5.1996 / 18:47:47 / cg"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   258
    "Created: 22.3.1997 / 16:44:29 / cg"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   259
!
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   260
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   261
nTally 
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   262
    "return the number of accumulated probes"
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   263
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   264
    ^ ntally
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   265
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   266
    "Modified: 18.5.1996 / 18:47:47 / cg"
0
470788421600 Initial revision
claus
parents:
diff changeset
   267
!
470788421600 Initial revision
claus
parents:
diff changeset
   268
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   269
probes
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   270
    "return the accumulated collection of flat probes"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   271
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   272
    ^ probes
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   273
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   274
    "Modified: 18.5.1996 / 18:47:57 / cg"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   275
    "Created: 20.3.1997 / 20:54:19 / cg"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   276
!
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   277
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   278
startTime
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   279
    "return the startTime of the run"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   280
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   281
    ^ startTime
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   282
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   283
    "Modified: 18.5.1996 / 18:47:47 / cg"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   284
    "Created: 22.3.1997 / 16:44:33 / cg"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   285
!
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   286
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   287
tree
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   288
    "return the accumulated calling tree"
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   289
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   290
    ^ tree
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   291
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   292
    "Modified: 18.5.1996 / 18:47:57 / cg"
0
470788421600 Initial revision
claus
parents:
diff changeset
   293
! !
470788421600 Initial revision
claus
parents:
diff changeset
   294
963
a4fb4b9f7e72 category change
Claus Gittinger <cg@exept.de>
parents: 957
diff changeset
   295
!MessageTally methodsFor:'printing & storing'!
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   296
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   297
printFlatMethodLeafsOn:aStream
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   298
    "print all flat method leafNodes statistics on aStream"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   299
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   300
    |leafNodes|
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   301
567
180b5d0da74b combine multiple invocations of the same method
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   302
    leafNodes := OrderedCollection new.
180b5d0da74b combine multiple invocations of the same method
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   303
    probes do:[:aProbe | aProbe addMethodLeafNodesTo:leafNodes].
180b5d0da74b combine multiple invocations of the same method
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   304
    leafNodes := leafNodes asSortedCollection:[:a :b |
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   305
                                        a leafTally < b leafTally].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   306
    leafNodes do:[:aNode |
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   307
        aNode leafTally ~= 0 ifTrue:[
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   308
            aNode printSingleMethodLeafOn:aStream.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   309
            aStream cr.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   310
        ]
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   311
    ].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   312
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   313
    "Created: 20.3.1997 / 20:56:13 / cg"
567
180b5d0da74b combine multiple invocations of the same method
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   314
    "Modified: 21.3.1997 / 10:18:31 / cg"
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   315
!
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   316
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   317
printFullStatisticOn:outStream
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   318
    "output full statistics on outstream"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   319
589
d2112d37ce36 removed unused variable
Claus Gittinger <cg@exept.de>
parents: 573
diff changeset
   320
    |runTime err|
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   321
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   322
    ntally == 0 ifTrue:[
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   323
        self printNoProbesOn:outStream.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   324
        ^ self
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   325
    ].
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   326
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   327
    tree computePercentage:ntally.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   328
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   329
    runTime := endTime - startTime.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   330
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   331
    outStream cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   332
    err := (1000 // ntally / 10.0).
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   333
    err > 0 ifTrue:[
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   334
        outStream nextPutLine:('total execution time: '
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   335
                           , runTime printString , ' ms '
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   336
                           , '(' , ntally printString , ' probes ;'
770
2edabfe333f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   337
                           , ' error ' 
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   338
                           , (1000 // ntally / 10.0) printString
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   339
                           , '%)'
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   340
                          ).
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   341
    ] ifFalse:[
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   342
        outStream nextPutLine:('total execution time: '
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   343
                           , runTime printString , ' ms '
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   344
                           , '(' , ntally printString , ' probes)'
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   345
                          ).
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   346
    ].
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   347
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   348
    outStream cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   349
    tree printOn:outStream.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   350
    outStream cr; cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   351
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   352
    outStream nextPutLine:'leafs of calling tree (by receiver & implementing method):'.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   353
    outStream cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   354
    tree printLeafsOn:outStream.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   355
    outStream cr; cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   356
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   357
    outStream nextPutLine:'method leafs of calling tree (by implementing method only):'.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   358
    outStream cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   359
    tree printMethodLeafsOn:outStream.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   360
    outStream cr; cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   361
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   362
    "Created: 22.3.1997 / 16:52:09 / cg"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   363
    "Modified: 22.3.1997 / 16:53:38 / cg"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   364
!
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   365
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   366
printLeafStatisticOn:outStream
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   367
    "output leaf statistics on outstream"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   368
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   369
    |runTime err|
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   370
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   371
    ntally == 0 ifTrue:[
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   372
        self printNoProbesOn:outStream.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   373
        ^ self.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   374
    ].
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   375
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   376
    runTime := endTime - startTime.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   377
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   378
    probes do:[:aProbe |
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   379
        aProbe computePercentage:ntally
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   380
    ].
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   381
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   382
    outStream cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   383
    err := (1000 // ntally / 10.0).
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   384
    err > 0 ifTrue:[
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   385
        outStream nextPutLine:('total execution time: '
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   386
                           , runTime printString , ' ms '
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   387
                           , '(' , ntally printString , ' probes ;'
770
2edabfe333f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   388
                           , ' error ' 
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   389
                           , (1000 // ntally / 10.0) printString
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   390
                           , '%)'
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   391
                          ).
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   392
    ] ifFalse:[
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   393
        outStream nextPutLine:('total execution time: '
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   394
                           , runTime printString , ' ms '
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   395
                           , '(' , ntally printString , ' probes)'
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   396
                          ).
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   397
    ].
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   398
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   399
    outStream nextPutLine:'method leafs of calling tree:'.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   400
    outStream cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   401
    self printFlatMethodLeafsOn:outStream.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   402
    outStream cr; cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   403
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   404
    "Created: 22.3.1997 / 16:50:06 / cg"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   405
    "Modified: 22.3.1997 / 16:53:15 / cg"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   406
!
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   407
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   408
printNoProbesOn:outStream
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   409
    "output a message that no probes are present"
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   410
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   411
    outStream cr.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   412
    outStream nextPutLine:'TALLY: No probes - execution time too short;'.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   413
    outStream nextPutLine:'TALLY: retry using: spyOn:[n timesRepeat:[...]]'.
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   414
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   415
    "Created: 22.3.1997 / 16:53:23 / cg"
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   416
! !
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   417
0
470788421600 Initial revision
claus
parents:
diff changeset
   418
!MessageTally methodsFor:'private'!
470788421600 Initial revision
claus
parents:
diff changeset
   419
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   420
execute
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   421
    "evaluate the target block"
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   422
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   423
    executing := true.
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   424
    ^ theBlock value
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   425
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   426
    "Modified: 20.3.1997 / 21:36:27 / cg"
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   427
! !
0
470788421600 Initial revision
claus
parents:
diff changeset
   428
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   429
!MessageTally methodsFor:'probing'!
21
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   430
c521be54a8e6 *** empty log message ***
claus
parents: 17
diff changeset
   431
count:aContext
260
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   432
    "entered whenever the probed block gets interrupted;
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   433
     look where it is, and remember in the calling tree"
bd12742cab04 commentary
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   434
263
4c3889934577 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   435
    "{ Pragma: +optSpeed }"
4c3889934577 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   436
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   437
    |chain|
0
470788421600 Initial revision
claus
parents:
diff changeset
   438
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   439
    chain := CallChain 
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   440
                callChainTo:aContext 
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   441
                stopAtCallerForWhich:[:con |
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   442
                    (con receiver == self) and:[con selector == #execute]
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   443
                ].
0
470788421600 Initial revision
claus
parents:
diff changeset
   444
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   445
    "add chain to the tree"
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   446
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   447
    chain notNil ifTrue:[
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   448
        ntally := ntally + 1.
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   449
        tree addChain:chain
0
470788421600 Initial revision
claus
parents:
diff changeset
   450
    ].
470788421600 Initial revision
claus
parents:
diff changeset
   451
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   452
    "Modified: / 04-07-2010 / 09:45:28 / cg"
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   453
!
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   454
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   455
countLeaf:aContext
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   456
    "entered whenever the probed block gets interrupted;
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   457
     look where it is, and remember in the flat profile"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   458
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   459
    "{ Pragma: +optSpeed }"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   460
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   461
    |con entry recClass selector mthdClass sender home existingEntry|
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   462
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   463
    con := aContext.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   464
    con isNil ifTrue:[^ self].
0
470788421600 Initial revision
claus
parents:
diff changeset
   465
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   466
    "walk up above the interrupt context"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   467
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   468
    [con receiver == Processor] whileTrue:[
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   469
        con := con sender
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   470
    ].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   471
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   472
    "got it - collect info from contexts"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   473
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   474
    con isNil ifTrue:[^ self].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   475
    ((con receiver == self) and:[con selector == #execute]) ifTrue:[^ self].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   476
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   477
    sender := con sender.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   478
    sender isNil ifTrue:[^ self].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   479
    ((sender receiver == self) and:[sender selector == #execute]) ifTrue:[^ self].
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   480
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   481
    home := con methodHome.
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   482
    home isNil ifTrue:[
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   483
        recClass := UndefinedObject.
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   484
        selector := 'optimized'.
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   485
        mthdClass := UndefinedObject.
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   486
    ] ifFalse:[
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   487
        recClass := home receiver class.
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   488
        selector := home selector.
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   489
        mthdClass := home methodClass.
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   490
    ].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   491
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   492
    "add info to the probes collection"
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   493
565
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   494
    ntally := ntally + 1.
01241f73a7a0 dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   495
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   496
    entry := ProfileTree new.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   497
    entry
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   498
        receiver:recClass
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   499
        selector:selector
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   500
        class:mthdClass
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   501
        isBlock:(con isBlockContext).
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   502
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   503
    existingEntry := probes elementAt:entry ifAbsent:nil.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   504
    existingEntry isNil ifTrue:[
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   505
        probes add:entry
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   506
    ] ifFalse:[
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   507
        existingEntry incrementLeafTally.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   508
    ].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   509
2281
859191db074f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2249
diff changeset
   510
    "Modified: / 04-07-2010 / 09:47:06 / cg"
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   511
! !
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   512
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   513
!MessageTally methodsFor:'spy setup'!
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   514
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   515
spyLeafOn:aBlock interval:ms
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   516
    "spy on execution time; generate information on leaf nodes only"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   517
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   518
    |probing delay probingProcess probedProcess|
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   519
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   520
    theBlock := aBlock.
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   521
1439
b58fa0afec58 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   522
    Processor activeProcess withPriority:(Processor userInterruptPriority-1) do:[
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   523
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   524
        probingProcess := [
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   525
            |p|
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   526
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   527
            p := probedProcess.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   528
            [probing] whileTrue:[
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   529
                delay wait.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   530
                executing ifTrue:[
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   531
                    self countLeaf:p suspendedContext
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   532
                ]
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   533
            ].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   534
        ] newProcess.
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   535
1439
b58fa0afec58 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1376
diff changeset
   536
        probingProcess priority:(Processor userInterruptPriority+1).
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   537
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   538
        delay := (Delay forMilliseconds:ms).
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   539
        ntally := 0.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   540
        probes := Set new:200.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   541
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   542
        probedProcess := Processor activeProcess.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   543
        
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   544
        executing := false.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   545
        probing := true.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   546
        probingProcess resume.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   547
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   548
        [
263
4c3889934577 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   549
            startTime := OperatingSystem getMillisecondTime.
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   550
            self execute.
1139
56861678ff27 #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   551
        ] ensure:[
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   552
            probing := executing := false.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   553
            theBlock := nil.
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   554
            endTime := OperatingSystem getMillisecondTime.
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   555
        ].
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   556
    ].
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   557
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   558
    "Created: 20.3.1997 / 20:15:07 / cg"
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   559
    "Modified: 22.3.1997 / 16:46:42 / cg"
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   560
!
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   561
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   562
spyOn:aBlock interval:ms
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   563
    "spy on execution time, generate a hierarchical call information"
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   564
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   565
    |probing delay probingProcess probedProcess retVal|
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   566
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   567
    theBlock := aBlock.
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   568
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   569
    Processor activeProcess 
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   570
        withPriority:(Processor userInterruptPriority-1) 
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   571
        do:[
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   572
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   573
            probingProcess := [
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   574
                |p|
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   575
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   576
                p := probedProcess.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   577
                [probing] whileTrue:[
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   578
                    delay wait.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   579
                    executing ifTrue:[
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   580
                        self count:p suspendedContext
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   581
                    ]
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   582
                ].
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   583
            ] newProcess.
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   584
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   585
            probingProcess priority:(Processor userInterruptPriority+1).
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   586
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   587
            delay := (Delay forMilliseconds:ms).
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   588
            ntally := 0.
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   589
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   590
            tree := ProfileTree new.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   591
            tree 
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   592
                receiver:MessageTally 
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   593
                selector:#execute 
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   594
                class:MessageTally
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   595
                isBlock:false.
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   596
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   597
            probedProcess := Processor activeProcess.
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   598
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   599
            executing := false.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   600
            probing := true.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   601
            probingProcess resume.
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   602
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   603
            [
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   604
                startTime := OperatingSystem getMillisecondTime.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   605
                retVal := self execute.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   606
            ] ensure:[
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   607
                probing := executing := false.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   608
                theBlock := nil.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   609
                endTime := OperatingSystem getMillisecondTime.
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   610
            ].
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   611
        ].
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   612
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   613
    ^ retVal
263
4c3889934577 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   614
564
d549f0b9c2f2 tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   615
    "Created: 20.3.1997 / 20:14:44 / cg"
571
58e603e1ce24 made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   616
    "Modified: 22.3.1997 / 16:45:42 / cg"
88
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   617
! !
070ba8eb911e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 68
diff changeset
   618
98
123d948aacd1 version at the end
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   619
!MessageTally class methodsFor:'documentation'!
123d948aacd1 version at the end
Claus Gittinger <cg@exept.de>
parents: 88
diff changeset
   620
261
2fb596a13d0c commentary
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   621
version
3011
1997ff6e7e55 trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2281
diff changeset
   622
    ^ '$Header: /cvs/stx/stx/libbasic3/MessageTally.st,v 1.46 2010/07/04 08:06:24 cg Exp $'
2249
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   623
!
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   624
b832323d4c13 changed:
Claus Gittinger <cg@exept.de>
parents: 1439
diff changeset
   625
version_CVS
3011
1997ff6e7e55 trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2281
diff changeset
   626
    ^ '§Header: /cvs/stx/stx/libbasic3/MessageTally.st,v 1.46 2010/07/04 08:06:24 cg Exp §'
1997ff6e7e55 trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2281
diff changeset
   627
! !