Skip to content

Commit

Permalink
- Adding matrix for the benchs
Browse files Browse the repository at this point in the history
- Adding Raw Benchs 
- Migrating Benchs
  • Loading branch information
tesonep committed Nov 26, 2024
1 parent 13d7dbd commit a8ca966
Show file tree
Hide file tree
Showing 33 changed files with 883 additions and 419 deletions.
29 changes: 29 additions & 0 deletions src/BlocBenchs-Benchs/BlBBoidsSkyCase.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Class {
#name : #BlBBoidsSkyCase,
#superclass : #BlBBlocCase,
#instVars : [
'element'
],
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #benchmarking }
BlBBoidsSkyCase class >> benchMatrix [

^ ParametrizedTestMatrix new
addCase: { #label -> 'BlBBoidsSkyCase using custom draw'. #element -> BoidsCustomDrawSkyElement new };
addCase: { #label -> 'BlBBoidsSkyCase using triangle geometry'. #element -> BoidsSkyUsingGeometryElement new };
addCase: { #label -> 'BlBBoidsSkyCase using custom geometry'. #element -> BoidCustomGeometrySkyElement new }.
]

{ #category : #accessing }
BlBBoidsSkyCase >> element: aBoidsCustomDrawSkyElement [

element := aBoidsCustomDrawSkyElement
]

{ #category : #'instance creation' }
BlBBoidsSkyCase >> newElement [

^ element
]
11 changes: 0 additions & 11 deletions src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st

This file was deleted.

47 changes: 47 additions & 0 deletions src/BlocBenchs-Benchs/BlBBoxWindmillBlocCase.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Class {
#name : #BlBBoxWindmillBlocCase,
#superclass : #BlBBlocCase,
#traits : 'TBlBBoxWindmillLogic',
#classTraits : 'TBlBBoxWindmillLogic classTrait',
#category : #'BlocBenchs-Benchs-Bloc'
}

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

| aContainerElement boxElements startMS |

aContainerElement := BlElement new
clipChildren: false;
size: self logicalExtent;
background: self backgroundColor;
yourself.

boxElements := self boxPositions collect: [ :eachPoint |
BlElement new
outskirts: BlOutskirts centered;
size: self boxExtent;
background: self boxColor;
position: eachPoint;
border: (BlBorder
paint: self boxBorderColor
width: self boxBorderWidth);
yourself ].
aContainerElement addChildren: boxElements.

startMS := Time millisecondClockValue.
aContainerElement addAnimation:
(BlBasicAnimation new
onStepDo: [ :t |
boxElements do:[ :each |
each transformDo: [ :builder |
builder
centerOrigin;
rotateBy: (self
boxRotationInDegreesWithPosition: each position
elapsedMS: Time millisecondClockValue - startMS) ] ] ];
yourself).

^ aContainerElement
]
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
Class {
#name : #PCBoxWindmillCompositingWindow,
#superclass : #PCBoxWindmillWindow,
#name : #BlBBoxWindmillCompositionRawCase,
#superclass : #BlBRawCase,
#traits : 'TBlBBoxWindmillLogic',
#classTraits : 'TBlBBoxWindmillLogic classTrait',
#instVars : [
'sdlRects',
'pixelBoxExtent',
'pixelBoxPositions',
'boxPositions',
'pixelBoxPositions',
'sdlRects',
'boxTextureStrategy'
],
#category : #'BlocBenchs-FPS-Raw'
#category : #'BlocBenchs-Benchs-Raw'
}

{ #category : #drawing }
PCBoxWindmillCompositingWindow >> drawOnCairoSurface [
BlBBoxWindmillCompositionRawCase >> drawBoxOn: aeCairoContext [

"set path (outskirts = center)"
aeCairoContext
rectangleX: self boxBorderWidth / 2
y: self boxBorderWidth / 2
width: self boxExtent x
height: self boxExtent y.

"draw background"
aeCairoContext
sourceColor: self boxColor;
fillPreserve.

"draw border"
aeCairoContext
sourceColor: self boxBorderColor;
lineWidth: self boxBorderWidth;
stroke.

]

{ #category : #'drawing - steps' }
BlBBoxWindmillCompositionRawCase >> drawOnCairoSurface [
"Completely done via composition of SDL textures"
]

{ #category : #drawing }
PCBoxWindmillCompositingWindow >> presentOnWindow [
{ #category : #'drawing - steps' }
BlBBoxWindmillCompositionRawCase >> presentOnWindow [

"Background"
sdlRenderer copy: mainTextureStrategy sdlTexture.
Expand All @@ -29,7 +54,7 @@ PCBoxWindmillCompositingWindow >> presentOnWindow [
copy: boxTextureStrategy sdlTexture
srcRect: SDL_Rect null
dstRect: (sdlRects at: index)
angle: (case
angle: (self
boxRotationInDegreesWithPosition: eachPosition
elapsedMS: self elapsedMillisecondsSinceFirstDraw)
center: SDL_Point null.
Expand All @@ -42,18 +67,27 @@ PCBoxWindmillCompositingWindow >> presentOnWindow [
sdlRenderer present
]

{ #category : #drawing }
PCBoxWindmillCompositingWindow >> resetAnimation [
{ #category : #'drawing - steps' }
BlBBoxWindmillCompositionRawCase >> setupMainTexture [

mainTextureStrategy := PCUpdateStaticTextureStrategy
newExtent: sdlRenderer outputExtent
renderer: sdlRenderer
setupBlock: setupBlock.

super resetAnimation.
mainTextureStrategy cairoContextDo: [ :aeCairoContext |
aeCairoContext
sourceColor: Color black;
paint.
].

"Adapt positions and extents to screen's scale factor"
pixelBoxExtent :=
(case boxExtent x * deviceScalePoint x) @
(case boxExtent y * deviceScalePoint y).
(self boxExtent x * deviceScalePoint x) @
(self boxExtent y * deviceScalePoint y).

boxPositions := case boxPositions.
pixelBoxPositions := case boxPositions: deviceScalePoint.
boxPositions := self boxPositions.
pixelBoxPositions := self boxPositions: deviceScalePoint.
sdlRects := pixelBoxPositions collect: [:each |
SDL_Rect
newX: each x
Expand All @@ -63,28 +97,11 @@ PCBoxWindmillCompositingWindow >> resetAnimation [

"Render a box in a static texture"
boxTextureStrategy := PCUpdateStaticTextureStrategy
newExtent: pixelBoxExtent + (case boxBorderWidth * deviceScalePoint)
newExtent: pixelBoxExtent + (self boxBorderWidth * deviceScalePoint)
renderer: sdlRenderer
setupBlock: self textureStrategySetupBlock.
setupBlock: setupBlock.
boxTextureStrategy setBlendEnabled.
boxTextureStrategy cairoContextDo: [ :aeCairoContext |
self drawBoxOn: aeCairoContext ]

]

{ #category : #accessing }
PCBoxWindmillCompositingWindow >> resetMainTexture [

mainTextureStrategy := PCUpdateStaticTextureStrategy
newExtent: sdlRenderer outputExtent
renderer: sdlRenderer
setupBlock: self textureStrategySetupBlock.

mainTextureStrategy cairoContextDo: [ :aeCairoContext |
aeCairoContext
sourceColor: Color black;
paint.
].

self resetAnimation
]
11 changes: 11 additions & 0 deletions src/BlocBenchs-Benchs/BlBClearCanvasRawCase.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Class {
#name : #BlBClearCanvasRawCase,
#superclass : #BlBRawCase,
#category : #'BlocBenchs-Benchs-Raw'
}

{ #category : #'as yet unclassified' }
BlBClearCanvasRawCase >> drawOnCairoSurface [

self clearCairoSurface
]
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
Class {
#name : #PCCompositionBenchCase,
#superclass : #PCBenchCase,
#category : #'BlocBenchs-FPS-Cases'
#name : #BlBCompositionCase,
#superclass : #BlBBlocCase,
#traits : 'TBlBCompositionLogic',
#classTraits : 'TBlBCompositionLogic classTrait',
#instVars : [
'useSingleComposition'
],
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #accessing }
PCCompositionBenchCase >> figureExtent [

^ 25 asPoint
]

{ #category : #accessing }
PCCompositionBenchCase >> layerExtent [

^ self logicalExtent / 1.5
]

{ #category : #accessing }
PCCompositionBenchCase >> logicalExtent [
{ #category : #benchmarking }
BlBCompositionCase class >> benchMatrix [

^ 700 @ 700
^ ParametrizedTestMatrix new
addCase: { #label -> 'BlBCompositionCase without using composition'. #useSingleComposition -> false};
addCase: { #label -> 'BlBCompositionCase without using composition'. #useSingleComposition -> true};
yourself
]

{ #category : #hook }
PCCompositionBenchCase >> newElement [
BlBCompositionCase >> newElement [

| random backgroundColorGenerator container staticComplexElement |
random := self newRandom.
Expand All @@ -45,13 +41,15 @@ PCCompositionBenchCase >> newElement [
1 to: self numberOfFigures do: [ :index |
staticComplexElement addChild: (self newFigure: random) ].
container addChild: staticComplexElement.
self prepareAsStatic: staticComplexElement.


useSingleComposition
ifTrue: [ staticComplexElement beInSingleCompositionLayer ].

^ container
]

{ #category : #hook }
PCCompositionBenchCase >> newFigure: random [
BlBCompositionCase >> newFigure: random [

^ BlElement new
background: (Color random: random);
Expand All @@ -60,21 +58,13 @@ PCCompositionBenchCase >> newFigure: random [
yourself
]

{ #category : #hook }
PCCompositionBenchCase >> nextLocation: random [

^ (random nextInteger: self layerExtent x - self figureExtent x)
@ (random nextInteger: self layerExtent y - self figureExtent y)
]

{ #category : #accessing }
PCCompositionBenchCase >> numberOfFigures [
BlBCompositionCase >> spaceExtent [

^ 5000
^ self logicalExtent
]

{ #category : #hook }
PCCompositionBenchCase >> prepareAsStatic: anElement [

self subclassResponsibility
{ #category : #accessing }
BlBCompositionCase >> useSingleComposition: aBoolean [
useSingleComposition := aBoolean
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ Class {
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #printing }
BlBToploListElementStresserWithAdditionalSelecters >> label [
{ #category : #initialization }
BlBToploListElementStresserWithAdditionalSelecters >> initialize [

^ 'Toplo list stress'
super initialize.
label := 'Toplo list stress'
]

{ #category : #'instance creation' }
Expand Down
Loading

0 comments on commit a8ca966

Please sign in to comment.