I imagine that this is this one

spyEvery: millisecs at: spyPriority on: aBlock
        "Create a spy and spy on the given block at the specified rate."

        | myDelay startTime time0 observedProcess |
        (aBlock isMemberOf: BlockClosure)
                ifFalse: [self error: 'spy needs a block here'].
        self class: aBlock receiver class method: aBlock method.
                "set up the probe"
        observedProcess :=  Processor activeProcess.
        myDelay := Delay forMilliseconds: millisecs.
        time0 := Time millisecondClockValue.
        gcStats :=  SmalltalkImage current getVMParameters.
        Timer :=  [
                [true] whileTrue: [
                        startTime := Time millisecondClockValue.
                        myDelay wait.
                        self tally: Processor preemptedProcess suspendedContext
                                in: (ShowProcesses ifTrue: [
                                        observedProcess == Processor 
preemptedProcess ifTrue:  
[observedProcess] ifFalse: [nil]])
                                "tally can be > 1 if ran a long primitive"
                                by: (Time millisecondClockValue - startTime) // 
millisecs].
                nil] newProcess.
        Timer priority: spyPriority.
                "activate the probe and evaluate the block"
        Timer resume.
        ^ aBlock ensure: [
                "Collect gc statistics"
                SmalltalkImage current getVMParameters keysAndValuesDo:  
[ :idx :gcVal |
                        gcStats at: idx put: (gcVal - (gcStats at: idx))].
                "cancel the probe and return the value"
                Timer terminate.
                time := Time millisecondClockValue - time0]

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to