Skip to content

Commit

Permalink
Add PCBenchmarkSuite>>run, to bench a case without opening a Spec window
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Sep 28, 2023
1 parent c7d8f35 commit 570d7c3
Show file tree
Hide file tree
Showing 77 changed files with 791 additions and 624 deletions.
16 changes: 9 additions & 7 deletions src/BlocBenchs-FPS/BlBasicAnimation.class.st
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
Class {
#name : #BlBasicAnimation,
#superclass : #BlBaseAnimation,
#name : 'BlBasicAnimation',
#superclass : 'BlBaseAnimation',
#instVars : [
'stepBlock'
],
#category : #'BlocBenchs-FPS-Utility'
#category : 'BlocBenchs-FPS-Utility',
#package : 'BlocBenchs-FPS',
#tag : 'Utility'
}

{ #category : #pulse }
{ #category : 'pulse' }
BlBasicAnimation >> doStep [
stepBlock cull: target
]

{ #category : #accessing }
{ #category : 'accessing' }
BlBasicAnimation >> duration [

^ 1 minute
]

{ #category : #accessing }
{ #category : 'accessing' }
BlBasicAnimation >> initialize [
super initialize.

self beInfinite.
]

{ #category : #pulse }
{ #category : 'pulse' }
BlBasicAnimation >> onStepDo: aBlock [
stepBlock := aBlock
]
28 changes: 15 additions & 13 deletions src/BlocBenchs-FPS/BlFPSTracer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ I trace to Transcript animation statistics of a Bloc space.
See an example of use on my class side.
"
Class {
#name : #BlFPSTracer,
#superclass : #Object,
#name : 'BlFPSTracer',
#superclass : 'Object',
#instVars : [
'framesDeltaMS',
'lastMS',
Expand All @@ -16,10 +16,12 @@ Class {
'spaceShownEventHandler',
'spaceRenderEndEventHandler'
],
#category : #'BlocBenchs-FPS-Utility'
#category : 'BlocBenchs-FPS-Utility',
#package : 'BlocBenchs-FPS',
#tag : 'Utility'
}

{ #category : #examples }
{ #category : 'examples' }
BlFPSTracer class >> exampleOfUse [
"The #start adds a handler to the space shown event, then it should be added before space show."

Expand All @@ -41,23 +43,23 @@ BlFPSTracer class >> exampleOfUse [

]

{ #category : #'instance creation' }
{ #category : 'instance creation' }
BlFPSTracer class >> newOnSpace: aSpace [

^ self basicNew
initializeOnSpace: aSpace;
yourself
]

{ #category : #'instance creation' }
{ #category : 'instance creation' }
BlFPSTracer class >> startOnSpace: aBlSpace [

^ (self newOnSpace: aBlSpace)
start;
yourself
]

{ #category : #displaying }
{ #category : 'displaying' }
BlFPSTracer >> forkLoopProcess [

loopProcess := [
Expand All @@ -79,7 +81,7 @@ BlFPSTracer >> forkLoopProcess [

]

{ #category : #displaying }
{ #category : 'displaying' }
BlFPSTracer >> initializeOnSpace: aSpace [

self initialize.
Expand Down Expand Up @@ -108,7 +110,7 @@ BlFPSTracer >> initializeOnSpace: aSpace [

]

{ #category : #printing }
{ #category : 'printing' }
BlFPSTracer >> printOn: aStream [

super printOn: aStream.
Expand All @@ -118,7 +120,7 @@ BlFPSTracer >> printOn: aStream [
nextPut: $)
]

{ #category : #displaying }
{ #category : 'displaying' }
BlFPSTracer >> printStatsOn: aStream [

aStream
Expand All @@ -133,14 +135,14 @@ BlFPSTracer >> printStatsOn: aStream [

]

{ #category : #displaying }
{ #category : 'displaying' }
BlFPSTracer >> resetFramesDeltaMS [

framesDeltaMS := LinkedList new.

]

{ #category : #displaying }
{ #category : 'displaying' }
BlFPSTracer >> start [

self trace. ' start' traceCr.
Expand All @@ -151,7 +153,7 @@ BlFPSTracer >> start [

]

{ #category : #displaying }
{ #category : 'displaying' }
BlFPSTracer >> stop [

self trace. ' stop' traceCr.
Expand Down
10 changes: 6 additions & 4 deletions src/BlocBenchs-FPS/PCAnnulusSectorBenchCase.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Class {
#name : #PCAnnulusSectorBenchCase,
#superclass : #PCTranslatingFiguresBenchCase,
#category : #'BlocBenchs-FPS-Cases'
#name : 'PCAnnulusSectorBenchCase',
#superclass : 'PCTranslatingFiguresBenchCase',
#category : 'BlocBenchs-FPS-Cases',
#package : 'BlocBenchs-FPS',
#tag : 'Cases'
}

{ #category : #hook }
{ #category : 'hook' }
PCAnnulusSectorBenchCase >> newFigureWith: random [

^ BlElement new
Expand Down
36 changes: 19 additions & 17 deletions src/BlocBenchs-FPS/PCBenchCase.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,45 @@ I define a case to be benchmarked by a PCBenchmarker.
"
Class {
#name : #PCBenchCase,
#superclass : #Object,
#name : 'PCBenchCase',
#superclass : 'Object',
#instVars : [
'numberOfSeconds'
],
#category : #'BlocBenchs-FPS-Cases'
#category : 'BlocBenchs-FPS-Cases',
#package : 'BlocBenchs-FPS',
#tag : 'Cases'
}

{ #category : #convenience }
{ #category : 'convenience' }
PCBenchCase class >> allBenchCases [

^ self allSubclasses
reject: [ :each | each hasAbstractMethods ]
thenCollect: [ :each | each new ]
]

{ #category : #convenience }
{ #category : 'convenience' }
PCBenchCase class >> allBenchCasesWithRaw [

^ self allBenchCases select: [ :each |
[ each newRawSDLCairoWindow. true ] onErrorDo: [ false ] ]

]

{ #category : #hook }
{ #category : 'hook' }
PCBenchCase >> angleInDegreesWith: random [

^ random nextInteger: 360
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCase >> duration [

^ numberOfSeconds seconds
]

{ #category : #initialization }
{ #category : 'initialization' }
PCBenchCase >> initialize [

super initialize.
Expand All @@ -48,7 +50,7 @@ PCBenchCase >> initialize [

]

{ #category : #printing }
{ #category : 'printing' }
PCBenchCase >> label [

| prefix suffix |
Expand All @@ -58,13 +60,13 @@ PCBenchCase >> label [
^ ' ' join: ((self className allButFirst: prefix size) allButLast: suffix size) splitCamelCase
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCase >> logicalExtent [

^ self subclassResponsibility
]

{ #category : #hook }
{ #category : 'hook' }
PCBenchCase >> newColorGenerator [

^ Generator on: [ :generator |
Expand All @@ -75,39 +77,39 @@ PCBenchCase >> newColorGenerator [
nextIndex := (nextIndex + 1) \\ wheel size + 1 ] repeat ]
]

{ #category : #hook }
{ #category : 'hook' }
PCBenchCase >> newElement [
"Answer the Bloc element to be added to the root of the space to setup the benchmark scenario."

^ self subclassResponsibility
]

{ #category : #private }
{ #category : 'private' }
PCBenchCase >> newRandom [

^ Random seed: 1
]

{ #category : #hook }
{ #category : 'hook' }
PCBenchCase >> newRawSDLCairoWindow [
"Answer a PCBenchCaseRawSDLCairoWindow instance to benchmark this case."

^ self notYetImplemented
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCase >> numberOfMilliseconds [

^ numberOfSeconds * 1000
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCase >> numberOfSeconds [

^ numberOfSeconds
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCase >> numberOfSeconds: aNumber [

numberOfSeconds := aNumber
Expand Down
30 changes: 16 additions & 14 deletions src/BlocBenchs-FPS/PCBenchCaseRawSDLCairoWindow.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #PCBenchCaseRawSDLCairoWindow,
#superclass : #PCRawSDLCairoWindow,
#name : 'PCBenchCaseRawSDLCairoWindow',
#superclass : 'PCRawSDLCairoWindow',
#instVars : [
'case',
'random',
Expand All @@ -9,42 +9,44 @@ Class {
'deltaMS',
'framesDeltaMS'
],
#category : #'BlocBenchs-FPS-Raw'
#category : 'BlocBenchs-FPS-Raw',
#package : 'BlocBenchs-FPS',
#tag : 'Raw'
}

{ #category : #'instance creation' }
{ #category : 'instance creation' }
PCBenchCaseRawSDLCairoWindow class >> newWith: aPCBenchCase [

^ self basicNew
initializeWith: aPCBenchCase;
yourself
]

{ #category : #hook }
{ #category : 'hook' }
PCBenchCaseRawSDLCairoWindow >> elapsedMillisecondsSinceFirstDraw [

^ lastMS - startMS
]

{ #category : #hook }
{ #category : 'hook' }
PCBenchCaseRawSDLCairoWindow >> elapsedTimeSinceFirstDraw [

^ self elapsedMillisecondsSinceFirstDraw milliSeconds
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCaseRawSDLCairoWindow >> frameCount [

^ framesDeltaMS size
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCaseRawSDLCairoWindow >> framesDeltaMS [

^ framesDeltaMS
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCaseRawSDLCairoWindow >> initializeWith: aPCBenchCase [

self initialize.
Expand All @@ -53,7 +55,7 @@ PCBenchCaseRawSDLCairoWindow >> initializeWith: aPCBenchCase [

]

{ #category : #'instance creation' }
{ #category : 'instance creation' }
PCBenchCaseRawSDLCairoWindow >> open [

self
Expand All @@ -62,7 +64,7 @@ PCBenchCaseRawSDLCairoWindow >> open [
extent: case logicalExtent
]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCaseRawSDLCairoWindow >> resetAnimation [
"Prepare to start drawing the animation from the biggining.
Subclasses can assume that Cairo and SDL surfaces are initialized."
Expand All @@ -78,23 +80,23 @@ PCBenchCaseRawSDLCairoWindow >> resetAnimation [

]

{ #category : #accessing }
{ #category : 'accessing' }
PCBenchCaseRawSDLCairoWindow >> resetMainTexture [

super resetMainTexture.

self resetAnimation.
]

{ #category : #hook }
{ #category : 'hook' }
PCBenchCaseRawSDLCairoWindow >> step [

self stepAnimation.
super step.

]

{ #category : #hook }
{ #category : 'hook' }
PCBenchCaseRawSDLCairoWindow >> stepAnimation [

| currentMS |
Expand Down
Loading

0 comments on commit 570d7c3

Please sign in to comment.