--- a/MessageTracer.st Thu Jul 30 16:53:29 1998 +0200
+++ b/MessageTracer.st Thu Jul 30 17:49:18 1998 +0200
@@ -15,7 +15,7 @@
classVariableNames:'BreakpointSignal CallingLevel BreakBlock TraceSenderBlock
TraceSenderBlock2 LeaveBreakBlock LeaveTraceBlock MethodCounts
MethodMemoryUsage MethodTiming TraceFullBlock TraceFullBlock2
- ObjectWrittenBreakpointSignal ObjectCopyHolders'
+ ObjectWrittenBreakpointSignal ObjectCopyHolders TimeForWrappers'
poolDictionaries:''
category:'System-Debugging-Support'
!
@@ -249,14 +249,26 @@
TraceFullBlock2 := [:con | con fullPrintAllOn:(Smalltalk at:#Transcript)].
LeaveBreakBlock := [:con :retVal | ].
LeaveTraceBlock := [:con :retVal | ].
- ]
+ ].
+
+ ObjectMemory addDependent:self.
"
BreakpointSignal := nil.
MessageTracer initialize
"
- "Modified: / 21.4.1998 / 14:38:35 / cg"
+ "Modified: / 30.7.1998 / 16:59:08 / cg"
+!
+
+update:something with:parameter from:changedObject
+ "sent when restarted after a snapIn"
+
+ (something == #restarted) ifTrue:[
+ TimeForWrappers := nil
+ ]
+
+ "Created: / 30.7.1998 / 17:00:09 / cg"
! !
!MessageTracer class methodsFor:'class tracing'!
@@ -724,6 +736,18 @@
"Modified: 15.12.1995 / 15:45:15 / cg"
!
+resetCountOfMethod:aMethod
+ "return the current count"
+
+ MethodCounts notNil ifTrue:[
+ aMethod isWrapped ifTrue:[
+ MethodCounts removeKey:aMethod originalMethod ifAbsent:nil.
+ ].
+ ].
+
+ "Created: / 30.7.1998 / 17:42:08 / cg"
+!
+
stopCountingMethod:aMethod
"remove counting of aMethod"
@@ -827,6 +851,21 @@
"Modified: 18.12.1995 / 16:25:51 / stefan"
!
+resetMemoryUsageOfMethod:aMethod
+ "reset the current usage"
+
+ MethodCounts notNil ifTrue:[
+ MethodMemoryUsage notNil ifTrue:[
+ aMethod isWrapped ifTrue:[
+ MethodCounts removeKey:aMethod originalMethod ifAbsent:nil.
+ MethodMemoryUsage removeKey:aMethod originalMethod ifAbsent:nil.
+ ]
+ ].
+ ].
+
+ "Created: / 30.7.1998 / 17:43:07 / cg"
+!
+
stopCountingMemoryUsageOfMethod:aMethod
"remove counting memory of aMethod"
@@ -838,7 +877,7 @@
!MessageTracer class methodsFor:'method timing'!
executionTimesOfMethod:aMethod
- "return the current gather execution times"
+ "return the current gathered execution time statistics"
|count info minT maxT avg ret|
@@ -852,7 +891,7 @@
count ~~ 0 ifTrue:[
minT := info at:2.
maxT := info at:3.
- avg := ((info at:4) / count) roundTo:0.01
+ avg := (info at:4) / count
]
].
].
@@ -860,12 +899,18 @@
(minT notNil and:[minT > 10]) ifTrue:[
minT := minT roundTo:0.1
+ ] ifFalse:[
+ minT := minT roundTo:0.01
].
(maxT notNil and:[maxT > 10]) ifTrue:[
maxT := maxT roundTo:0.1
+ ] ifFalse:[
+ maxT := maxT roundTo:0.01
].
(avg notNil and:[avg > 10]) ifTrue:[
avg := avg roundTo:0.1
+ ] ifFalse:[
+ avg := avg roundTo:0.01
].
ret := IdentityDictionary new.
@@ -876,7 +921,20 @@
^ ret
"Created: / 17.6.1996 / 17:07:30 / cg"
- "Modified: / 30.7.1998 / 16:51:44 / cg"
+ "Modified: / 30.7.1998 / 17:36:46 / cg"
+!
+
+resetExecutionTimesOfMethod:aMethod
+ "reset the gathered execution times statistics for aMethod;
+ the method remains wrapped."
+
+ MethodTiming notNil ifTrue:[
+ aMethod isWrapped ifTrue:[
+ MethodTiming removeKey:aMethod originalMethod ifAbsent:nil.
+ ].
+ ].
+
+ "Created: / 30.7.1998 / 17:12:35 / cg"
!
stopTimingMethod:aMethod
@@ -890,9 +948,9 @@
timeMethod:aMethod
"arrange for a aMethods execution time to be measured.
- Use unwrapMethod to remove this."
-
- |t0 timeToGetTime|
+ Use unwrapMethod: or stopTimingMethod: to remove this."
+
+ |t0|
MethodTiming isNil ifTrue:[
MethodTiming := IdentityDictionary new.
@@ -903,8 +961,9 @@
with:0
with:0).
- t0 := OperatingSystem getMicrosecondTime.
- timeToGetTime := (OperatingSystem getMicrosecondTime - t0).
+ TimeForWrappers isNil ifTrue:[
+ self getTimeForWrappers
+ ].
^ self wrapMethod:aMethod
onEntry:[:con |
@@ -914,7 +973,8 @@
|info t cnt minT maxT sumTimes|
t := OperatingSystem getMicrosecondTime - t0.
- t := t - timeToGetTime.
+ t := t - TimeForWrappers.
+ t < 0 ifTrue:[t := 0].
t := t / 1000.0.
info := MethodTiming at:aMethod ifAbsent:nil.
@@ -957,7 +1017,7 @@
"
"Created: / 17.6.1996 / 17:03:50 / cg"
- "Modified: / 30.7.1998 / 16:48:25 / cg"
+ "Modified: / 30.7.1998 / 17:13:11 / cg"
! !
!MessageTracer class methodsFor:'method tracing'!
@@ -2419,6 +2479,48 @@
!MessageTracer class methodsFor:'trace helpers'!
+dummyEmptyMethod
+ "helper - to get the time it takes to evaluate the wrappers for
+ a dummy method."
+
+ "Created: / 30.7.1998 / 16:58:08 / cg"
+!
+
+getTimeForWrappers
+ "helper - get the overhead (in ms) spent in the wrapper code of
+ a timed method."
+
+ |m times|
+
+ TimeForWrappers := 0.
+
+ "/ wrap the dummy method ...
+
+ m := self class compiledMethodAt:#dummyEmptyMethod.
+ m := self timeMethod:m.
+
+ "/ invoke it a few times ...
+ "/ (cannot take the smallest, since the work done in the wrapper
+ "/ depends on whether there is already some statistic data)
+
+ 10 timesRepeat:[
+ self dummyEmptyMethod.
+ ].
+
+ "/ fetch min time & unwrap
+
+ times := self executionTimesOfMethod:m.
+ self stopTimingMethod:m.
+
+ ^ (TimeForWrappers := times at:#avgTime)
+
+ "
+ self getTimeForWrappers
+ "
+
+ "Modified: / 30.7.1998 / 17:10:07 / cg"
+!
+
printEntryFull:aContext
self printEntryFull:aContext level:0 on:Stderr
!
@@ -2624,6 +2726,6 @@
!MessageTracer class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic3/MessageTracer.st,v 1.68 1998-07-30 14:53:29 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic3/MessageTracer.st,v 1.69 1998-07-30 15:49:18 cg Exp $'
! !
MessageTracer initialize!