Skip to content

Commit

Permalink
Migrating Benchs
Browse files Browse the repository at this point in the history
  • Loading branch information
tesonep committed Dec 3, 2024
1 parent 09ae5c9 commit 9a0529d
Show file tree
Hide file tree
Showing 35 changed files with 646 additions and 580 deletions.
46 changes: 46 additions & 0 deletions src/BlocBenchs-Benchs/BlBAbstractCircleCase.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Class {
#name : #BlBAbstractCircleCase,
#superclass : #BlBAbstractTranslatingFiguresCase,
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #running }
BlBAbstractCircleCase class >> isAbstract [

^ self == BlBAbstractCircleCase
]

{ #category : #hook }
BlBAbstractCircleCase >> newFigureWith: random [

^ BlElement new
geometry: BlCircleGeometry new;
size: self radius * 2;
in:[ :me | self prepare: me with: random ];
yourself

]

{ #category : #accessing }
BlBAbstractCircleCase >> numberOfFigures [

^ 100
]

{ #category : #accessing }
BlBAbstractCircleCase >> offsetBetweenFigures [

^ 6 @ 0
]

{ #category : #hook }
BlBAbstractCircleCase >> prepare: anElement with: random [

^ self subclassResponsibility
]

{ #category : #accessing }
BlBAbstractCircleCase >> radius [

^ 50.0 asPoint
]
68 changes: 68 additions & 0 deletions src/BlocBenchs-Benchs/BlBAbstractGradientCirclesCase.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Class {
#name : #BlBAbstractGradientCirclesCase,
#superclass : #BlBAbstractCircleCase,
#instVars : [
'numberOfStops'
],
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #running }
BlBAbstractGradientCirclesCase class >> benchMatrix [

^ super benchMatrix
forSelector: #numberOfStops addOptions: #(2 3 5)
]

{ #category : #running }
BlBAbstractGradientCirclesCase class >> isAbstract [

^ self == BlBAbstractGradientCirclesCase
]

{ #category : #accessing }
BlBAbstractGradientCirclesCase >> defaultLabel [

^ '{1} w/ {2} stops' format: {
super defaultLabel.
numberOfStops }
]

{ #category : #hook }
BlBAbstractGradientCirclesCase >> initialize [

super initialize.

numberOfStops := 3.
]

{ #category : #hook }
BlBAbstractGradientCirclesCase >> newGradient: random [

^ self subclassResponsibility
]

{ #category : #hook }
BlBAbstractGradientCirclesCase >> newStops: random [

^ (0.0 to: 1.0 by: 1 / (numberOfStops - 1)) collect: [ :each |
each -> (Color random: random) ]
]

{ #category : #accessing }
BlBAbstractGradientCirclesCase >> numberOfStops [

^ numberOfStops
]

{ #category : #accessing }
BlBAbstractGradientCirclesCase >> numberOfStops: anInteger [

numberOfStops := anInteger
]

{ #category : #hook }
BlBAbstractGradientCirclesCase >> prepare: anElement with: random [

anElement background: (self newGradient: random)
]
35 changes: 35 additions & 0 deletions src/BlocBenchs-Benchs/BlBAbstractImagesCase.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Class {
#name : #BlBAbstractImagesCase,
#superclass : #BlBAbstractTranslatingFiguresCase,
#traits : 'TBlBAbstractImagesLogic',
#classTraits : 'TBlBAbstractImagesLogic classTrait',
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #running }
BlBAbstractImagesCase class >> isAbstract [

^ self == BlBAbstractImagesCase
]

{ #category : #hook }
BlBAbstractImagesCase >> newFigureWith: random [

| container |
container := BlElement new.
container clipChildren: false.

1 to: self numberOfRows do:[ :index |
container addChild:
((self newImageElementWith: random)
position: 0 @ (index * self offsetBetweenFigures y);
yourself) ].

^ container
]

{ #category : #hook }
BlBAbstractImagesCase >> newImageElementWith: random [

^ self subclassResponsibility
]
133 changes: 133 additions & 0 deletions src/BlocBenchs-Benchs/BlBAbstractTranslatingFiguresCase.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
Class {
#name : #BlBAbstractTranslatingFiguresCase,
#superclass : #BlBBlocCase,
#instVars : [
'useSingleAnimation'
],
#category : #'BlocBenchs-Benchs-Bloc'
}

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

^ super benchMatrix
forSelector: #useSingleAnimation
addOptions: #( true false )
]

{ #category : #running }
BlBAbstractTranslatingFiguresCase class >> isAbstract [

^ self == BlBAbstractTranslatingFiguresCase
]

{ #category : #accessing }
BlBAbstractTranslatingFiguresCase >> defaultLabel [

^ super defaultLabel , ' singleAnimation: ' , useSingleAnimation printString
]

{ #category : #accessing }
BlBAbstractTranslatingFiguresCase >> figureOffset [

^ 20 @ 20
]

{ #category : #hook }
BlBAbstractTranslatingFiguresCase >> newElement [

^ useSingleAnimation
ifTrue: [ self newElementWithSingleAnimation ]
ifFalse: [ self newElementWithIndependentAnimations ]
]

{ #category : #hook }
BlBAbstractTranslatingFiguresCase >> newElementWithIndependentAnimations [

| random container |
random := self newRandom.
container := BlElement new
size: self spaceExtent;
yourself.

1 to: self numberOfFigures do: [ :index |
| aFigure |
aFigure := self newFigureWith: random.
aFigure position: self figureOffset + ((index * self offsetBetweenFigures x) @ 0).
aFigure addAnimation: ((BlTransformAnimation translate: self targetTranslation)
duration: self duration;
yourself).

container addChild: aFigure ].

^ container
]

{ #category : #hook }
BlBAbstractTranslatingFiguresCase >> newElementWithSingleAnimation [

| random container |
random := self newRandom.
container := BlElement new
size: self spaceExtent;
addAnimation: ((BlTransformAnimation translate: self targetTranslation)
duration: self duration;
yourself);
yourself.

1 to: self numberOfFigures do: [ :index |
| aFigure |
aFigure := self newFigureWith: random.
aFigure position: self figureOffset + ((index * self offsetBetweenFigures x) @ 0).
container addChild: aFigure ].

^ container
]

{ #category : #hook }
BlBAbstractTranslatingFiguresCase >> newFigureWith: random [

^ self subclassResponsibility
]

{ #category : #examples }
BlBAbstractTranslatingFiguresCase >> newSampleFigure [

^ self newFigureWith: self newRandom
]

{ #category : #accessing }
BlBAbstractTranslatingFiguresCase >> numberOfFigures [

^ 300
]

{ #category : #hook }
BlBAbstractTranslatingFiguresCase >> offsetBetweenFigures [

^ 2 @ 0
]

{ #category : #hooks }
BlBAbstractTranslatingFiguresCase >> spaceExtent [

^ 750 @ 350
]

{ #category : #accessing }
BlBAbstractTranslatingFiguresCase >> targetTranslation [

^ 0 @ 200
]

{ #category : #accessing }
BlBAbstractTranslatingFiguresCase >> useSingleAnimation [

^ useSingleAnimation
]

{ #category : #accessing }
BlBAbstractTranslatingFiguresCase >> useSingleAnimation: aBoolean [

useSingleAnimation := aBoolean
]
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Class {
#name : #PCAnnulusSectorBenchCase,
#superclass : #PCTranslatingFiguresBenchCase,
#category : #'BlocBenchs-FPS-Cases'
#name : #BlBAnnulusSectorCase,
#superclass : #BlBAbstractTranslatingFiguresCase,
#category : #'BlocBenchs-Benchs-Bloc'
}

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

^ BlElement new
background: (Color random: random);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Class {
#name : #PCClippedImagesBenchCase,
#superclass : #PCImagesBenchCase,
#category : #'BlocBenchs-FPS-Cases'
#name : #BlBClippedImagesCase,
#superclass : #BlBAbstractImagesCase,
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #'instance creation' }
PCClippedImagesBenchCase >> newImageElementWith: random [
BlBClippedImagesCase >> newImageElementWith: random [

| randomIcon |
randomIcon := self newFormWith: random.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Class {
#name : #PCDashedBorderCirclesBenchCase,
#superclass : #PCCirclesBenchCase,
#category : #'BlocBenchs-FPS-Cases'
#name : #BlBDashedBorderCirclesCase,
#superclass : #BlBAbstractCircleCase,
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #accessing }
PCDashedBorderCirclesBenchCase >> borderWidth [
BlBDashedBorderCirclesCase >> borderWidth [

^ 10
]

{ #category : #hook }
PCDashedBorderCirclesBenchCase >> prepare: anElement with: random [
BlBDashedBorderCirclesCase >> prepare: anElement with: random [

anElement border:
(BlBorder builder
Expand Down
15 changes: 15 additions & 0 deletions src/BlocBenchs-Benchs/BlBLinearGradientCirclesCase.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Class {
#name : #BlBLinearGradientCirclesCase,
#superclass : #BlBAbstractGradientCirclesCase,
#category : #'BlocBenchs-Benchs-Bloc'
}

{ #category : #hook }
BlBLinearGradientCirclesCase >> newGradient: random [

^ BlLinearGradientPaint new
start: 0 asPoint;
end: 2 * self radius;
stops: (self newStops: random);
yourself.
]
Loading

0 comments on commit 9a0529d

Please sign in to comment.