Skip to content

Commit

Permalink
Merge pull request #647 from pharo-graphics/adding-stats-window
Browse files Browse the repository at this point in the history
Adding stats window
  • Loading branch information
tesonep authored Nov 21, 2024
2 parents 996e234 + e068977 commit b4a09d7
Show file tree
Hide file tree
Showing 6 changed files with 449 additions and 103 deletions.
102 changes: 0 additions & 102 deletions src/Bloc-DevTool/BlBenchmarkConsole.class.st

This file was deleted.

54 changes: 54 additions & 0 deletions src/Bloc-DevTool/BlProfilingSpaceFrame.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"
I am a subclass of BlSpaceFrame to replace the it with profiling extensions
"
Class {
#name : #BlProfilingSpaceFrame,
#superclass : #BlSpaceFrame,
#instVars : [
'spaceStatistics'
],
#category : #'Bloc-DevTool-Profiling'
}

{ #category : #initialization }
BlProfilingSpaceFrame >> fillFrom: aBlSpaceFrame [

id := aBlSpaceFrame id.
phases := aBlSpaceFrame phases.
currentPhaseLink := (aBlSpaceFrame instVarNamed: #currentPhaseLink)
]

{ #category : #running }
BlProfilingSpaceFrame >> runCurrentPhaseOn: aSpace [

| millis |
millis := [ self currentPhase runOn: aSpace ] millisecondsToRun.

spaceStatistics recordMilliseconds: millis forFramePhase: self currentPhase
]

{ #category : #running }
BlProfilingSpaceFrame >> runOn: aSpace [
self incrementFrameId.

spaceStatistics frameStarted: id.

self runCurrentPhaseOn: aSpace.

[ self hasNextPhase ] whileTrue: [
self switchToNextPhase.
self runCurrentPhaseOn: aSpace ].

"move back to the first phase"
self switchToNextPhase.

spaceStatistics frameEnded: id.

]

{ #category : #accessing }
BlProfilingSpaceFrame >> spaceStatistics: aPRSpaceStatistics [

spaceStatistics := aPRSpaceStatistics

]
42 changes: 42 additions & 0 deletions src/Bloc-DevTool/BlSpace.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,45 @@ BlSpace >> addHalosListener [

self root addEventFilter: BlDevHalosEventListener new
]

{ #category : #'*Bloc-DevTool' }
BlSpace >> enableStatistics [

| spaceStatistics |

self spaceStatistics ifNotNil: [ ^ self ].

spaceStatistics := BlSpaceStatistics new
space: self;
yourself.

frame := BlProfilingSpaceFrame new
fillFrom: frame;
spaceStatistics: spaceStatistics;
yourself.

self addEventHandlerOn: BlSpaceShownEvent do: [ spaceStatistics spaceShown ].
self addEventHandlerOn: BlSpaceClosedEvent do: [ spaceStatistics spaceClosed ].

self userData at: #spaceStatistics put: spaceStatistics
]

{ #category : #'*Bloc-DevTool' }
BlSpace >> showStatisticsWindow [

(BlSpaceStatisticsWindow for: self) open
]

{ #category : #'*Bloc-DevTool' }
BlSpace >> showStatisticsWindowAndKeptOpen [

(BlSpaceStatisticsWindow for: self)
keepOpened;
open
]

{ #category : #'*Bloc-DevTool' }
BlSpace >> spaceStatistics [

^ self userData at: #spaceStatistics ifAbsent: [ nil ].
]
Loading

0 comments on commit b4a09d7

Please sign in to comment.