From 5c828fd859ca1471776febea8a1fed78db7ee43c Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Tue, 19 Nov 2024 15:14:15 +0100 Subject: [PATCH 01/23] Using BlocStatistics for calculating FPS --- src/BlocBenchs-Old/BlFFICounter.class.st | 15 ++-- src/BlocBenchs-Old/BlFrameMeter.class.st | 96 ++++-------------------- 2 files changed, 20 insertions(+), 91 deletions(-) diff --git a/src/BlocBenchs-Old/BlFFICounter.class.st b/src/BlocBenchs-Old/BlFFICounter.class.st index f6ec6b4..e238016 100644 --- a/src/BlocBenchs-Old/BlFFICounter.class.st +++ b/src/BlocBenchs-Old/BlFFICounter.class.st @@ -2,8 +2,7 @@ Class { #name : #BlFFICounter, #superclass : #BlMeter, #instVars : [ - 'functionNamesAndCounts', - 'frameCount' + 'functionNamesAndCounts' ], #category : #'BlocBenchs-Old-ProfileCases' } @@ -55,18 +54,18 @@ BlFFICounter >> startMetering [ "Really start" TFLFunctionCounter start. - "Count frames" - frameCount := 0. - case space - addEventHandlerOn: BlSpaceRenderEndEvent - do: [ :evt | - frameCount := frameCount + 1 ]. + case space enableStatistics. ] { #category : #API } BlFFICounter >> stopMetering [ + "Extract relevant information of the global logger, and reset it." + | frameCount | + + frameCount := case space spaceStatistics totalFrames. + functionNamesAndCounts := TFLFunctionCounter instance functionNamesAndCounts. functionNamesAndCounts := OrderedDictionary newFrom: (functionNamesAndCounts associations sorted: [ :a :b | diff --git a/src/BlocBenchs-Old/BlFrameMeter.class.st b/src/BlocBenchs-Old/BlFrameMeter.class.st index 3339d7e..d4f1556 100644 --- a/src/BlocBenchs-Old/BlFrameMeter.class.st +++ b/src/BlocBenchs-Old/BlFrameMeter.class.st @@ -1,71 +1,42 @@ Class { #name : #BlFrameMeter, #superclass : #BlMeter, - #instVars : [ - 'process', - 'framesAndMicrosendTimestamps', - 'frameCount' - ], #category : #'BlocBenchs-Old-ProfileCases' } -{ #category : #private } -BlFrameMeter >> fpsFrom: frameAndMicrosendTimestampA to: frameAndMicrosendTimestampB [ - - | totalSeconds | - totalSeconds := (Duration microSeconds: - frameAndMicrosendTimestampB value - frameAndMicrosendTimestampA value) totalSeconds. - - ^ (frameAndMicrosendTimestampB key - frameAndMicrosendTimestampA key) / totalSeconds - -] - -{ #category : #accessing } -BlFrameMeter >> intermediateFPS [ - - ^ framesAndMicrosendTimestamps overlappingPairsCollect: [ :a :b | - self fpsFrom: a to: b ] -] - -{ #category : #private } -BlFrameMeter >> registerSampleNow [ - - framesAndMicrosendTimestamps add: - frameCount -> Time microsecondClockValue -] - { #category : #printing } BlFrameMeter >> reportAsStringOn: stream [ + | stats fpsSamples | + + stats := case space spaceStatistics. + fpsSamples := stats fpsSamples allButFirst collect: [:e | e second]. + stream << 'Number of samples:'; lf; tab; - print: framesAndMicrosendTimestamps size; + print: fpsSamples size; lf. - framesAndMicrosendTimestamps size >= 1 ifFalse: [ ^ self ]. - stream << 'Frame count:'; lf; tab; - print: framesAndMicrosendTimestamps last key; + print: stats totalFrames; lf. - framesAndMicrosendTimestamps size >= 2 ifFalse: [ ^ self ]. + fpsSamples ifEmpty: [ ^ self ]. stream << 'FPS mean and error margin (90% confidence level):'; lf; tab; - << (MeanConfidenceIntervalPrinter new print: self intermediateFPS); + << (MeanConfidenceIntervalPrinter new print: fpsSamples); lf. - framesAndMicrosendTimestamps size > 2 ifFalse: [ ^ self ]. - stream << 'FPS samples:'; lf. - self intermediateFPS withIndexDo: [ :fps :index | + fpsSamples withIndexDo: [ :fps :index | stream tab; print: index; @@ -89,53 +60,12 @@ BlFrameMeter >> reportsAsPagesUsing: aBuilder [ { #category : #API } BlFrameMeter >> startMetering [ - "Start a high-priority process that will tally the space's frame id. The id of a space increases on every new frame. - " - - | delay | - framesAndMicrosendTimestamps := OrderedCollection new. - delay := Delay forSeconds: 1. - - "Count frames" - frameCount := 0. - case space - addEventHandlerOn: BlSpaceRenderEndEvent - do: [ :evt | - frameCount := frameCount + 1 ]. - - - [ process := Processor activeProcess. - - [[ process == Processor activeProcess ] whileTrue: [ - - "Add a new sample" - self registerSampleNow. - - delay wait. - ]] onErrorDo:[ :e | process := nil. e traceCr ] - ] forkAt: Processor highestPriority - 1 + case space enableStatistics ] { #category : #API } BlFrameMeter >> stopMetering [ - - process terminate. - process := nil. -] - -{ #category : #accessing } -BlFrameMeter >> totalFPS [ - - ^ self - fpsFrom: framesAndMicrosendTimestamps first - to: framesAndMicrosendTimestamps last -] - -{ #category : #accessing } -BlFrameMeter >> totalSeconds [ - "Answer the number of elapsed seconds, expressed as a Float." - - ^ (Duration microSeconds: framesAndMicrosendTimestamps last value - - framesAndMicrosendTimestamps first value) totalSeconds + + ] From b89a7e8d39dd9f0f280af9a2a1627bef3ac87a16 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 22 Nov 2024 11:52:24 +0100 Subject: [PATCH 02/23] - Extracting the bench runner and putting them in BlocBenchs-Core - Convert old benchmakrs into new format --- .../BlBAbstractSimpleAnimationCase.class.st | 31 +++++ .../BlBAbstractTextEditorCase.class.st | 80 +++++++++++ .../BlBBackgroundColorCase.class.st} | 13 +- .../BlBBoidsSkyUsingCustomDrawCase.class.st | 11 ++ ...SkyUsingCustomGeometryElementCase.class.st | 11 ++ ...BBoidsSkyUsingGeometryElementCase.class.st | 11 ++ .../BlBDefaultElementCase.class.st | 11 ++ .../BlBGridLayoutForceLayoutingCase.class.st | 32 +++++ ...BHighlightOnMouseMoveProfileCase.class.st} | 39 ++---- .../BlBKeysCursorMoveTextEditorCase.class.st | 33 +++++ ...BlBMouseWheelScrollTextEditorCase.class.st | 20 +++ ...ntStresserWithAdditionalSelecters.class.st | 17 +++ .../BlBTranslateCase.class.st | 16 +++ src/BlocBenchs-Benchs/package.st | 1 + .../BlAllocationsMeter.class.st | 30 ++++ .../BlBBlocBenchRunner.class.st | 102 ++++++++++++++ src/BlocBenchs-Core/BlBBlocCase.class.st | 29 ++++ src/BlocBenchs-Core/BlBCase.class.st | 58 ++++++++ src/BlocBenchs-Core/BlBMeter.class.st | 5 + .../BlBRenderingMeter.class.st | 51 +++++++ src/BlocBenchs-Core/BlBResult.class.st | 29 ++++ src/BlocBenchs-Core/BlBTimeMeter.class.st | 31 +++++ src/BlocBenchs-Core/package.st | 1 + .../BlBAbstractSimpleAnimationCase.class.st | 31 +++++ .../BlBoidsProfileCase.class.st | 80 ----------- .../BlFixedDurationProfileCase.class.st | 39 ------ ...ysCursorMoveTextEditorProfileCase.class.st | 45 ------ ...eWheelScrollTextEditorProfileCase.class.st | 34 ----- src/BlocBenchs-Old/BlProfileCase.class.st | 130 ------------------ .../BlSimpleElementProfileCase.class.st | 28 ---- .../BlTextEditorProfileCase.class.st | 92 ------------- .../BlTranslateProfileCase.class.st | 16 --- .../ToListStressProfileCase.class.st | 33 ----- 33 files changed, 660 insertions(+), 530 deletions(-) create mode 100644 src/BlocBenchs-Benchs/BlBAbstractSimpleAnimationCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBAbstractTextEditorCase.class.st rename src/{BlocBenchs-Old/BlBackgroundColorProfileCase.class.st => BlocBenchs-Benchs/BlBBackgroundColorCase.class.st} (69%) create mode 100644 src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomGeometryElementCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBDefaultElementCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBGridLayoutForceLayoutingCase.class.st rename src/{BlocBenchs-Old/BlHighlightOnMouseMoveProfileCase.class.st => BlocBenchs-Benchs/BlBHighlightOnMouseMoveProfileCase.class.st} (69%) create mode 100644 src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBMouseWheelScrollTextEditorCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBToploListElementStresserWithAdditionalSelecters.class.st create mode 100644 src/BlocBenchs-Benchs/BlBTranslateCase.class.st create mode 100644 src/BlocBenchs-Benchs/package.st create mode 100644 src/BlocBenchs-Core/BlAllocationsMeter.class.st create mode 100644 src/BlocBenchs-Core/BlBBlocBenchRunner.class.st create mode 100644 src/BlocBenchs-Core/BlBBlocCase.class.st create mode 100644 src/BlocBenchs-Core/BlBCase.class.st create mode 100644 src/BlocBenchs-Core/BlBMeter.class.st create mode 100644 src/BlocBenchs-Core/BlBRenderingMeter.class.st create mode 100644 src/BlocBenchs-Core/BlBResult.class.st create mode 100644 src/BlocBenchs-Core/BlBTimeMeter.class.st create mode 100644 src/BlocBenchs-Core/package.st create mode 100644 src/BlocBenchs-Old/BlBAbstractSimpleAnimationCase.class.st delete mode 100644 src/BlocBenchs-Old/BlBoidsProfileCase.class.st delete mode 100644 src/BlocBenchs-Old/BlFixedDurationProfileCase.class.st delete mode 100644 src/BlocBenchs-Old/BlKeysCursorMoveTextEditorProfileCase.class.st delete mode 100644 src/BlocBenchs-Old/BlMouseWheelScrollTextEditorProfileCase.class.st delete mode 100644 src/BlocBenchs-Old/BlProfileCase.class.st delete mode 100644 src/BlocBenchs-Old/BlSimpleElementProfileCase.class.st delete mode 100644 src/BlocBenchs-Old/BlTextEditorProfileCase.class.st delete mode 100644 src/BlocBenchs-Old/BlTranslateProfileCase.class.st delete mode 100644 src/BlocBenchs-Old/ToListStressProfileCase.class.st diff --git a/src/BlocBenchs-Benchs/BlBAbstractSimpleAnimationCase.class.st b/src/BlocBenchs-Benchs/BlBAbstractSimpleAnimationCase.class.st new file mode 100644 index 0000000..0e3e75d --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBAbstractSimpleAnimationCase.class.st @@ -0,0 +1,31 @@ +" +I'm a profiling case with an animated BlElement. +" +Class { + #name : #BlBAbstractSimpleAnimationCase, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #running } +BlBAbstractSimpleAnimationCase class >> isAbstract [ + + ^ self == BlBAbstractSimpleAnimationCase +] + +{ #category : #hooks } +BlBAbstractSimpleAnimationCase >> newElement [ + + ^ BlElement new + position: 100 asPoint; + size: 100 asPoint; + border: (BlBorder paint: Color gray width: 4); + addAnimation: (self newSteppingAnimation); + yourself +] + +{ #category : #'instance creation' } +BlBAbstractSimpleAnimationCase >> newSteppingAnimation [ + + ^ self subclassResponsibility +] diff --git a/src/BlocBenchs-Benchs/BlBAbstractTextEditorCase.class.st b/src/BlocBenchs-Benchs/BlBAbstractTextEditorCase.class.st new file mode 100644 index 0000000..4712527 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBAbstractTextEditorCase.class.st @@ -0,0 +1,80 @@ +" +I'm a profiling case where a text editor is scrolled down multiple times. +" +Class { + #name : #BlBAbstractTextEditorCase, + #superclass : #BlBBlocCase, + #instVars : [ + 'editorElement', + 'lapseToWaitBetween', + 'numberOfSimulatedEvents' + ], + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #running } +BlBAbstractTextEditorCase class >> isAbstract [ + + ^ self == BlBAbstractTextEditorCase +] + +{ #category : #accessing } +BlBAbstractTextEditorCase >> defaultLapseToWait [ + + ^ 0.5 seconds +] + +{ #category : #accessing } +BlBAbstractTextEditorCase >> defaultNumberOfSimulatedEvents [ + + ^ 15 +] + +{ #category : #hooks } +BlBAbstractTextEditorCase >> dispatchEvent [ + + self subclassResponsibility +] + +{ #category : #accessing } +BlBAbstractTextEditorCase >> lapseToWaitBetween [ + + ^ lapseToWaitBetween ifNil: [ lapseToWaitBetween := self defaultLapseToWait ] +] + +{ #category : #accessing } +BlBAbstractTextEditorCase >> lapseToWaitBetween: aDuration [ + + lapseToWaitBetween := aDuration +] + +{ #category : #hooks } +BlBAbstractTextEditorCase >> newElement [ + + ^ editorElement := ToAlbum new + text: (String loremIpsum: 20000) asRopedText; + withRowNumbers; + enqueueTask: (BlRepeatedTaskAction new + delay: self lapseToWaitBetween; + action: [ self dispatchEvent ]); + yourself +] + +{ #category : #accessing } +BlBAbstractTextEditorCase >> numberOfSimulatedEvents [ + + ^ numberOfSimulatedEvents ifNil: [ + numberOfSimulatedEvents := self defaultNumberOfSimulatedEvents ] +] + +{ #category : #accessing } +BlBAbstractTextEditorCase >> numberOfSimulatedEvents: anInteger [ + + numberOfSimulatedEvents := anInteger +] + +{ #category : #hooks } +BlBAbstractTextEditorCase >> spaceExtent [ + + ^ 500 @ 900 +] diff --git a/src/BlocBenchs-Old/BlBackgroundColorProfileCase.class.st b/src/BlocBenchs-Benchs/BlBBackgroundColorCase.class.st similarity index 69% rename from src/BlocBenchs-Old/BlBackgroundColorProfileCase.class.st rename to src/BlocBenchs-Benchs/BlBBackgroundColorCase.class.st index 8dd0a10..0f605ee 100644 --- a/src/BlocBenchs-Old/BlBackgroundColorProfileCase.class.st +++ b/src/BlocBenchs-Benchs/BlBBackgroundColorCase.class.st @@ -2,17 +2,18 @@ I'm a profiling case with a BlElement that changes background color on each frame with an infinite animation. " Class { - #name : #BlBackgroundColorProfileCase, - #superclass : #BlSimpleElementProfileCase, - #category : #'BlocBenchs-Old-ProfileCases' + #name : #BlBBackgroundColorCase, + #superclass : #BlBAbstractSimpleAnimationCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #'instance creation' } -BlBackgroundColorProfileCase >> newSteppingAnimation [ +BlBBackgroundColorCase >> newSteppingAnimation [ | colorGenerator | colorGenerator := Generator on: [ :generator | - | nextIndex wheel| + | nextIndex wheel | + nextIndex := 1. wheel := Color wheel: 50. [ generator yield: (wheel at: nextIndex). @@ -21,7 +22,7 @@ BlBackgroundColorProfileCase >> newSteppingAnimation [ ^ BlNumberTransition new from: 0; to: 1; - onStepDo: [ :t | + onStepDo: [ :t :element | element background: colorGenerator next ]; beInfinite; yourself diff --git a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st new file mode 100644 index 0000000..91a02c2 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st @@ -0,0 +1,11 @@ +Class { + #name : #BlBBoidsSkyUsingCustomDrawCase, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #'instance creation' } +BlBBoidsSkyUsingCustomDrawCase >> newElement [ + + ^ BoidsCustomDrawSkyElement new +] diff --git a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomGeometryElementCase.class.st b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomGeometryElementCase.class.st new file mode 100644 index 0000000..1a545c2 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomGeometryElementCase.class.st @@ -0,0 +1,11 @@ +Class { + #name : #BlBBoidsSkyUsingCustomGeometryElementCase, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #'instance creation' } +BlBBoidsSkyUsingCustomGeometryElementCase >> newElement [ + + ^ BoidCustomGeometrySkyElement new +] diff --git a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st new file mode 100644 index 0000000..6b844a8 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st @@ -0,0 +1,11 @@ +Class { + #name : #BlBBoidsSkyUsingGeometryElementCase, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #'instance creation' } +BlBBoidsSkyUsingGeometryElementCase >> newElement [ + + ^ BoidsSkyUsingGeometryElement new +] diff --git a/src/BlocBenchs-Benchs/BlBDefaultElementCase.class.st b/src/BlocBenchs-Benchs/BlBDefaultElementCase.class.st new file mode 100644 index 0000000..d31e37a --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBDefaultElementCase.class.st @@ -0,0 +1,11 @@ +Class { + #name : #BlBDefaultElementCase, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #'instance creation' } +BlBDefaultElementCase >> newElement [ + + ^ BlElement new +] diff --git a/src/BlocBenchs-Benchs/BlBGridLayoutForceLayoutingCase.class.st b/src/BlocBenchs-Benchs/BlBGridLayoutForceLayoutingCase.class.st new file mode 100644 index 0000000..2fd2142 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBGridLayoutForceLayoutingCase.class.st @@ -0,0 +1,32 @@ +Class { + #name : #BlBGridLayoutForceLayoutingCase, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #'instance creation' } +BlBGridLayoutForceLayoutingCase >> newElement [ + + | container | + container := BlElement new. + container layout: (BlGridLayout new columnCount: 3). + container layout cellSpacing: 3. + container constraintsDo: [ :c | + c vertical matchParent. + c horizontal matchParent ]. + + 30 timesRepeat: [ + container addChild: (BlElement new + background: Color random; + height: 50; + width: 50; + yourself) ]. + + container addAnimation: (BlBasicAnimation new + onStepDo: [ :target | + target children asArray shuffle. + target requestLayout ]; + yourself). + + ^ container +] diff --git a/src/BlocBenchs-Old/BlHighlightOnMouseMoveProfileCase.class.st b/src/BlocBenchs-Benchs/BlBHighlightOnMouseMoveProfileCase.class.st similarity index 69% rename from src/BlocBenchs-Old/BlHighlightOnMouseMoveProfileCase.class.st rename to src/BlocBenchs-Benchs/BlBHighlightOnMouseMoveProfileCase.class.st index 5e51930..63b8871 100644 --- a/src/BlocBenchs-Old/BlHighlightOnMouseMoveProfileCase.class.st +++ b/src/BlocBenchs-Benchs/BlBHighlightOnMouseMoveProfileCase.class.st @@ -4,28 +4,13 @@ I'm a benchmarking case that simulates mouse move in a circle over a grid of ele This is a scenario where updating only dirty rectangles can benefit. " Class { - #name : #BlHighlightOnMouseMoveProfileCase, - #superclass : #BlFixedDurationProfileCase, - #category : #'BlocBenchs-Old-ProfileCases' + #name : #BlBHighlightOnMouseMoveProfileCase, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' } -{ #category : #examples } -BlHighlightOnMouseMoveProfileCase class >> example [ - - [ | case | - case := self new - hostClass: BlOSWindowSDL2Host; - yourself. - - (BlProfileRunner newForCase: case) - enableASProfiler; - enableFPS; - run; - openMeterReports ] fork -] - { #category : #hooks } -BlHighlightOnMouseMoveProfileCase >> newElement [ +BlBHighlightOnMouseMoveProfileCase >> newElement [ "Answer the element under study." | columnCount rowCount boardExtent cellExtent board | @@ -67,17 +52,17 @@ BlHighlightOnMouseMoveProfileCase >> newElement [ ] { #category : #private } -BlHighlightOnMouseMoveProfileCase >> newSteppingAnimation [ +BlBHighlightOnMouseMoveProfileCase >> newSteppingAnimation [ | oldPosition newPosition center | newPosition := 0.0 asPoint. center := self spaceExtent / 2. ^ BlNumberTransition new - duration: duration; + duration: self duration; from: 0.0; to: Float twoPi; - onStepDo: [ :angle | + onStepDo: [ :angle :target | | anEvent | oldPosition := newPosition. newPosition := @@ -85,22 +70,22 @@ BlHighlightOnMouseMoveProfileCase >> newSteppingAnimation [ + ((center x * angle cos) @ (center y * angle sin)). anEvent := BlMouseMoveEvent new position: newPosition; - screenPosition: space position + newPosition; + screenPosition: target space position + newPosition; delta: newPosition - oldPosition; - timestamp: space time now; + timestamp: target space time now; yourself. - space dispatchEvent: anEvent ]; + target space dispatchEvent: anEvent ]; yourself ] { #category : #private } -BlHighlightOnMouseMoveProfileCase >> numberOfCellsOnEachSide [ +BlBHighlightOnMouseMoveProfileCase >> numberOfCellsOnEachSide [ ^ 100 ] { #category : #hooks } -BlHighlightOnMouseMoveProfileCase >> spaceExtent [ +BlBHighlightOnMouseMoveProfileCase >> spaceExtent [ ^ 500 asPoint ] diff --git a/src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st b/src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st new file mode 100644 index 0000000..c70f1c1 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st @@ -0,0 +1,33 @@ +" +Profile case that emulates a user pressing down arrow repeated times. +" +Class { + #name : #BlBKeysCursorMoveTextEditorCase, + #superclass : #BlBAbstractTextEditorCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #hooks } +BlBKeysCursorMoveTextEditorCase >> defaultLapseToWait [ + + ^ 100 milliSeconds +] + +{ #category : #accessing } +BlBKeysCursorMoveTextEditorCase >> defaultNumberOfSimulatedEvents [ + + ^ 40 +] + +{ #category : #hooks } +BlBKeysCursorMoveTextEditorCase >> dispatchEvent [ + + | key | + key := KeyboardKey down. + + { BlKeyDownEvent new. BlKeyUpEvent new } do: [ :anEvent | + anEvent key: key. + 'aaa' traceCr. + MorphicRenderLoop new doOneCycle. + editorElement space dispatchEventWithTimestamp: anEvent ] +] diff --git a/src/BlocBenchs-Benchs/BlBMouseWheelScrollTextEditorCase.class.st b/src/BlocBenchs-Benchs/BlBMouseWheelScrollTextEditorCase.class.st new file mode 100644 index 0000000..1afd1d1 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBMouseWheelScrollTextEditorCase.class.st @@ -0,0 +1,20 @@ +" +Profile case that emulates a user scrolling down using the wheel. +" +Class { + #name : #BlBMouseWheelScrollTextEditorCase, + #superclass : #BlBAbstractTextEditorCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #hooks } +BlBMouseWheelScrollTextEditorCase >> dispatchEvent [ + + | anEvent | + anEvent := BlMouseWheelEvent new + vector: (BlVector x: 0 y: -7); + position: editorElement bounds inSpace center; + yourself. + + editorElement space dispatchEventWithTimestamp: anEvent +] diff --git a/src/BlocBenchs-Benchs/BlBToploListElementStresserWithAdditionalSelecters.class.st b/src/BlocBenchs-Benchs/BlBToploListElementStresserWithAdditionalSelecters.class.st new file mode 100644 index 0000000..ec68628 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBToploListElementStresserWithAdditionalSelecters.class.st @@ -0,0 +1,17 @@ +Class { + #name : #BlBToploListElementStresserWithAdditionalSelecters, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #printing } +BlBToploListElementStresserWithAdditionalSelecters >> label [ + + ^ 'Toplo list stress' +] + +{ #category : #'instance creation' } +BlBToploListElementStresserWithAdditionalSelecters >> newElement [ + + ^ ToListElementStresserWithAdditionalSelecters new tabsPanel +] diff --git a/src/BlocBenchs-Benchs/BlBTranslateCase.class.st b/src/BlocBenchs-Benchs/BlBTranslateCase.class.st new file mode 100644 index 0000000..55c0c3a --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBTranslateCase.class.st @@ -0,0 +1,16 @@ +" +I'm a profiling case with a BlElement that translates during a period of time. +" +Class { + #name : #BlBTranslateCase, + #superclass : #BlBAbstractSimpleAnimationCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #'instance creation' } +BlBTranslateCase >> newSteppingAnimation [ + + ^ (BlTransformAnimation translate: 0@200) + duration: self duration; + yourself +] diff --git a/src/BlocBenchs-Benchs/package.st b/src/BlocBenchs-Benchs/package.st new file mode 100644 index 0000000..0d66602 --- /dev/null +++ b/src/BlocBenchs-Benchs/package.st @@ -0,0 +1 @@ +Package { #name : #'BlocBenchs-Benchs' } diff --git a/src/BlocBenchs-Core/BlAllocationsMeter.class.st b/src/BlocBenchs-Core/BlAllocationsMeter.class.st new file mode 100644 index 0000000..0a800a2 --- /dev/null +++ b/src/BlocBenchs-Core/BlAllocationsMeter.class.st @@ -0,0 +1,30 @@ +Class { + #name : #BlAllocationsMeter, + #superclass : #BlBMeter, + #instVars : [ + 'initialAllocationBytes', + 'finalAllocationBytes' + ], + #category : #'BlocBenchs-Core' +} + +{ #category : #'as yet unclassified' } +BlAllocationsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + + aBlBResult + addField: #allocatedBytes + title: 'Allocated Memory (Bytes)' + value: finalAllocationBytes - initialAllocationBytes +] + +{ #category : #'as yet unclassified' } +BlAllocationsMeter >> startMetering: aBlBBlocBenchRunner [ + + initialAllocationBytes := Smalltalk vm getParameters at: 34. +] + +{ #category : #'as yet unclassified' } +BlAllocationsMeter >> stopMetering: aBlBBlocBenchRunner [ + + finalAllocationBytes := Smalltalk vm getParameters at: 34. +] diff --git a/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st b/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st new file mode 100644 index 0000000..5252632 --- /dev/null +++ b/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st @@ -0,0 +1,102 @@ +Class { + #name : #BlBBlocBenchRunner, + #superclass : #Object, + #instVars : [ + 'space', + 'result', + 'meters', + 'duration' + ], + #category : #'BlocBenchs-Core' +} + +{ #category : #'as yet unclassified' } +BlBBlocBenchRunner >> cleanUpAfterCase [ + + space ifNil: [ ^ self ]. + + space close. + space spaceStatistics ifNotNil: [ :stats | stats spaceClosed ]. + +] + +{ #category : #running } +BlBBlocBenchRunner >> defaultMeters [ + + ^ { + BlBTimeMeter new. + BlBRenderingMeter new. + BlAllocationsMeter new } +] + +{ #category : #'as yet unclassified' } +BlBBlocBenchRunner >> doRun: aBlBBlocCase [ + + duration + ifNotNil: [ aBlBBlocCase duration: duration ] + ifNil: [ duration := aBlBBlocCase duration ]. + + space extent: aBlBBlocCase spaceExtent. + space root addChild: aBlBBlocCase newElement. + space root children first requestFocus. + space show. + aBlBBlocCase duration wait. + + +] + +{ #category : #accessing } +BlBBlocBenchRunner >> duration: aDuration [ + duration := aDuration +] + +{ #category : #running } +BlBBlocBenchRunner >> meters [ + + ^ meters ifNil: [ meters := self defaultMeters ] +] + +{ #category : #'as yet unclassified' } +BlBBlocBenchRunner >> prepareBeforeRun [ + + space := BlSpace new +] + +{ #category : #running } +BlBBlocBenchRunner >> reportMeters [ + + self meters do: [:e | e reportResultsFrom: self in: result]. +] + +{ #category : #running } +BlBBlocBenchRunner >> runCase: aCase [ + + result := BlBResult new. + result initializeFrom: aCase. + + ^ [ + self prepareBeforeRun. + self startMeters. + self doRun: aCase. + self stopMeters. + self reportMeters. + result + ] ensure: [ self cleanUpAfterCase ] +] + +{ #category : #accessing } +BlBBlocBenchRunner >> space [ + ^ space +] + +{ #category : #running } +BlBBlocBenchRunner >> startMeters [ + + self meters do: [:e | e startMetering: self]. +] + +{ #category : #running } +BlBBlocBenchRunner >> stopMeters [ + + self meters reverse do: [:e | e stopMetering: self]. +] diff --git a/src/BlocBenchs-Core/BlBBlocCase.class.st b/src/BlocBenchs-Core/BlBBlocCase.class.st new file mode 100644 index 0000000..1b3558a --- /dev/null +++ b/src/BlocBenchs-Core/BlBBlocCase.class.st @@ -0,0 +1,29 @@ +Class { + #name : #BlBBlocCase, + #superclass : #BlBCase, + #category : #'BlocBenchs-Core' +} + +{ #category : #running } +BlBBlocCase class >> isAbstract [ + + ^ self == BlBBlocCase +] + +{ #category : #accessing } +BlBBlocCase >> defaultRunnerClass [ + + ^ BlBBlocBenchRunner +] + +{ #category : #'instance creation' } +BlBBlocCase >> newElement [ + + ^ self subclassResponsibility +] + +{ #category : #hooks } +BlBBlocCase >> spaceExtent [ + + ^ 800@600 +] diff --git a/src/BlocBenchs-Core/BlBCase.class.st b/src/BlocBenchs-Core/BlBCase.class.st new file mode 100644 index 0000000..effe21c --- /dev/null +++ b/src/BlocBenchs-Core/BlBCase.class.st @@ -0,0 +1,58 @@ +Class { + #name : #BlBCase, + #superclass : #Object, + #instVars : [ + 'runner', + 'result', + 'duration' + ], + #category : #'BlocBenchs-Core' +} + +{ #category : #running } +BlBCase class >> isAbstract [ + + ^ self == BlBCase +] + +{ #category : #running } +BlBCase class >> run [ + + ^ self new run +] + +{ #category : #'accessing - defaults' } +BlBCase >> defaultDuration [ + + ^ 10 seconds +] + +{ #category : #accessing } +BlBCase >> duration [ + + ^ duration ifNil: [ self defaultDuration ] +] + +{ #category : #accessing } +BlBCase >> duration: aDuration [ + + duration := aDuration +] + +{ #category : #accessing } +BlBCase >> label [ + + ^ self class name +] + +{ #category : #running } +BlBCase >> run [ + + ^ self runner runCase: self +] + +{ #category : #running } +BlBCase >> runner [ + + ^ runner ifNil: [ runner := self defaultRunnerClass new ] +] diff --git a/src/BlocBenchs-Core/BlBMeter.class.st b/src/BlocBenchs-Core/BlBMeter.class.st new file mode 100644 index 0000000..8b91246 --- /dev/null +++ b/src/BlocBenchs-Core/BlBMeter.class.st @@ -0,0 +1,5 @@ +Class { + #name : #BlBMeter, + #superclass : #Object, + #category : #'BlocBenchs-Core' +} diff --git a/src/BlocBenchs-Core/BlBRenderingMeter.class.st b/src/BlocBenchs-Core/BlBRenderingMeter.class.st new file mode 100644 index 0000000..bc3a522 --- /dev/null +++ b/src/BlocBenchs-Core/BlBRenderingMeter.class.st @@ -0,0 +1,51 @@ +Class { + #name : #BlBRenderingMeter, + #superclass : #BlBMeter, + #category : #'BlocBenchs-Core' +} + +{ #category : #'as yet unclassified' } +BlBRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + + | stats fpsSamples | + stats := aBlBBlocBenchRunner space spaceStatistics. + fpsSamples := stats fpsSamples allButFirst collect: [:e | e second]. + + aBlBResult + addField: #totalRenderTime + title: 'Total Render Time (ms)' + value: stats totalTime. + + aBlBResult + addField: #frameCount + title: 'Frame Count' + value: stats totalFrames. + + aBlBResult + addField: #fps + title: 'FPS mean and error margin (90% confidence level)' + value: (MeanConfidenceIntervalPrinter new print: fpsSamples). + + aBlBResult + addField: #fpsSamples + title: 'Raw FPS samples' + value: stats fpsSamples. + + aBlBResult + addField: #phaseStatistics + title: 'Phase Statistics' + value: stats phaseStatistics + +] + +{ #category : #'as yet unclassified' } +BlBRenderingMeter >> startMetering: aBlBBlocBenchRunner [ + + aBlBBlocBenchRunner space enableStatistics +] + +{ #category : #'as yet unclassified' } +BlBRenderingMeter >> stopMetering: aBlBBlocBenchRunner [ + + +] diff --git a/src/BlocBenchs-Core/BlBResult.class.st b/src/BlocBenchs-Core/BlBResult.class.st new file mode 100644 index 0000000..cac0752 --- /dev/null +++ b/src/BlocBenchs-Core/BlBResult.class.st @@ -0,0 +1,29 @@ +Class { + #name : #BlBResult, + #superclass : #Object, + #instVars : [ + 'content', + 'caseClassName', + 'caseLabel' + ], + #category : #'BlocBenchs-Core' +} + +{ #category : #adding } +BlBResult >> addField: aFieldName title: aTitle value: aValue [ + + self content at: aFieldName put: { aTitle. aValue } +] + +{ #category : #accessing } +BlBResult >> content [ + + ^ content ifNil: [ content := Dictionary new ] +] + +{ #category : #initialization } +BlBResult >> initializeFrom: aBlBCase [ + + caseClassName := aBlBCase class name. + caseLabel := aBlBCase label +] diff --git a/src/BlocBenchs-Core/BlBTimeMeter.class.st b/src/BlocBenchs-Core/BlBTimeMeter.class.st new file mode 100644 index 0000000..2d8381f --- /dev/null +++ b/src/BlocBenchs-Core/BlBTimeMeter.class.st @@ -0,0 +1,31 @@ +Class { + #name : #BlBTimeMeter, + #superclass : #BlBMeter, + #instVars : [ + 'initialTime', + 'finalTime' + ], + #category : #'BlocBenchs-Core' +} + +{ #category : #'as yet unclassified' } +BlBTimeMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + + aBlBResult + addField: #totalTime + title: 'Total Time (ms)' + value: finalTime - initialTime. + +] + +{ #category : #'as yet unclassified' } +BlBTimeMeter >> startMetering: aBlBBlocBenchRunner [ + + initialTime := Time millisecondClockValue +] + +{ #category : #'as yet unclassified' } +BlBTimeMeter >> stopMetering: aBlBBlocBenchRunner [ + + finalTime := Time millisecondClockValue +] diff --git a/src/BlocBenchs-Core/package.st b/src/BlocBenchs-Core/package.st new file mode 100644 index 0000000..f1047d3 --- /dev/null +++ b/src/BlocBenchs-Core/package.st @@ -0,0 +1 @@ +Package { #name : #'BlocBenchs-Core' } diff --git a/src/BlocBenchs-Old/BlBAbstractSimpleAnimationCase.class.st b/src/BlocBenchs-Old/BlBAbstractSimpleAnimationCase.class.st new file mode 100644 index 0000000..0e3e75d --- /dev/null +++ b/src/BlocBenchs-Old/BlBAbstractSimpleAnimationCase.class.st @@ -0,0 +1,31 @@ +" +I'm a profiling case with an animated BlElement. +" +Class { + #name : #BlBAbstractSimpleAnimationCase, + #superclass : #BlBBlocCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #running } +BlBAbstractSimpleAnimationCase class >> isAbstract [ + + ^ self == BlBAbstractSimpleAnimationCase +] + +{ #category : #hooks } +BlBAbstractSimpleAnimationCase >> newElement [ + + ^ BlElement new + position: 100 asPoint; + size: 100 asPoint; + border: (BlBorder paint: Color gray width: 4); + addAnimation: (self newSteppingAnimation); + yourself +] + +{ #category : #'instance creation' } +BlBAbstractSimpleAnimationCase >> newSteppingAnimation [ + + ^ self subclassResponsibility +] diff --git a/src/BlocBenchs-Old/BlBoidsProfileCase.class.st b/src/BlocBenchs-Old/BlBoidsProfileCase.class.st deleted file mode 100644 index d90c54d..0000000 --- a/src/BlocBenchs-Old/BlBoidsProfileCase.class.st +++ /dev/null @@ -1,80 +0,0 @@ -" -Profiling case where Boids example is shown in a space during some seconds. -" -Class { - #name : #BlBoidsProfileCase, - #superclass : #BlFixedDurationProfileCase, - #instVars : [ - 'boidsSkyElementClass' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #examples } -BlBoidsProfileCase class >> exampleFFI [ - - [ | case | - case := self new - hostClass: BlOSWindowSDL2Host; - yourself. - - (BlProfileRunner newForCase: case) - enableFFICounter; -" enableFFILogger;" - run; - openMeterReports ] fork -] - -{ #category : #examples } -BlBoidsProfileCase class >> exampleFPS [ - - [ | case | - case := self new - hostClass: BlOSWindowSDL2Host; - yourself. - - (BlProfileRunner newForCase: case) - enableFPS; - run; - openMeterReports ] fork -] - -{ #category : #examples } -BlBoidsProfileCase class >> exampleProfile [ - - [ | case | - case := self new - hostClass: BlOSWindowSDL2Host; - yourself. - - (BlProfileRunner newForCase: case) - enableASProfiler; - run; - openMeterReports ] fork -] - -{ #category : #accessing } -BlBoidsProfileCase >> boidsSkyElementClass [ - - ^ boidsSkyElementClass -] - -{ #category : #accessing } -BlBoidsProfileCase >> boidsSkyElementClass: aBoidsSkyElementClass [ - - boidsSkyElementClass := aBoidsSkyElementClass -] - -{ #category : #initialization } -BlBoidsProfileCase >> initialize [ - - super initialize. - - boidsSkyElementClass := BoidsSkyUsingGeometryElement -] - -{ #category : #hooks } -BlBoidsProfileCase >> newElement [ - - ^ boidsSkyElementClass new -] diff --git a/src/BlocBenchs-Old/BlFixedDurationProfileCase.class.st b/src/BlocBenchs-Old/BlFixedDurationProfileCase.class.st deleted file mode 100644 index 1212793..0000000 --- a/src/BlocBenchs-Old/BlFixedDurationProfileCase.class.st +++ /dev/null @@ -1,39 +0,0 @@ -" -Profiling case where a BlElement is shown in a space during some seconds. - -" -Class { - #name : #BlFixedDurationProfileCase, - #superclass : #BlProfileCase, - #instVars : [ - 'duration' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #accessing } -BlFixedDurationProfileCase >> duration [ - - ^ duration -] - -{ #category : #accessing } -BlFixedDurationProfileCase >> duration: aDuration [ - - duration := aDuration -] - -{ #category : #hooks } -BlFixedDurationProfileCase >> executeBody [ - - self duration wait -] - -{ #category : #initialization } -BlFixedDurationProfileCase >> initialize [ - - super initialize. - - duration := 5 seconds - -] diff --git a/src/BlocBenchs-Old/BlKeysCursorMoveTextEditorProfileCase.class.st b/src/BlocBenchs-Old/BlKeysCursorMoveTextEditorProfileCase.class.st deleted file mode 100644 index 9007986..0000000 --- a/src/BlocBenchs-Old/BlKeysCursorMoveTextEditorProfileCase.class.st +++ /dev/null @@ -1,45 +0,0 @@ -" -Profile case that emulates a user pressing down arrow repeated times. -" -Class { - #name : #BlKeysCursorMoveTextEditorProfileCase, - #superclass : #BlTextEditorProfileCase, - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #examples } -BlKeysCursorMoveTextEditorProfileCase class >> example [ - - [ | case | - case := self new - hostClass: BlOSWindowSDL2Host; - yourself. - - (BlProfileRunner newForCase: case) - enableASProfiler; - run; - openMeterReports ] fork -] - -{ #category : #hooks } -BlKeysCursorMoveTextEditorProfileCase >> defaultLapseToWait [ - - ^ 100 milliSeconds -] - -{ #category : #accessing } -BlKeysCursorMoveTextEditorProfileCase >> defaultNumberOfSimulatedEvents [ - - ^ 40 -] - -{ #category : #hooks } -BlKeysCursorMoveTextEditorProfileCase >> dispatchEvent [ - - | key | - key := KeyboardKey down. - - { BlKeyDownEvent new. BlKeyUpEvent new } do: [ :anEvent | - anEvent key: key. - editorElement space dispatchEventWithTimestamp: anEvent ] -] diff --git a/src/BlocBenchs-Old/BlMouseWheelScrollTextEditorProfileCase.class.st b/src/BlocBenchs-Old/BlMouseWheelScrollTextEditorProfileCase.class.st deleted file mode 100644 index 17977be..0000000 --- a/src/BlocBenchs-Old/BlMouseWheelScrollTextEditorProfileCase.class.st +++ /dev/null @@ -1,34 +0,0 @@ -" -Profile case that emulates a user scrolling down using the wheel. -" -Class { - #name : #BlMouseWheelScrollTextEditorProfileCase, - #superclass : #BlTextEditorProfileCase, - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #examples } -BlMouseWheelScrollTextEditorProfileCase class >> example [ - - [ | case | - case := self new - hostClass: BlOSWindowSDL2Host; - yourself. - - (BlProfileRunner newForCase: case) - enableASProfiler; - run; - openMeterReports ] fork -] - -{ #category : #hooks } -BlMouseWheelScrollTextEditorProfileCase >> dispatchEvent [ - - | anEvent | - anEvent := BlMouseWheelEvent new - vector: (BlVector x: 0 y: -7); - position: editorElement bounds inSpace center; - yourself. - - editorElement space dispatchEventWithTimestamp: anEvent -] diff --git a/src/BlocBenchs-Old/BlProfileCase.class.st b/src/BlocBenchs-Old/BlProfileCase.class.st deleted file mode 100644 index 7f4630d..0000000 --- a/src/BlocBenchs-Old/BlProfileCase.class.st +++ /dev/null @@ -1,130 +0,0 @@ -" -I'm a Bloc case to be profiled. - -Concrete cases define several hooks: -- newElement, that answers a BlElement that will be added and shown in a space. -- executeBody, that defines the code to profile. - -Cases have a hostClass and a spartaCanvasClass that must be set to the space and the Bloc global before openSpace. - -" -Class { - #name : #BlProfileCase, - #superclass : #Object, - #instVars : [ - 'space', - 'hostClass' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #API } -BlProfileCase >> closeSpace [ - - space close -] - -{ #category : #API } -BlProfileCase >> executeBody [ -] - -{ #category : #accessing } -BlProfileCase >> hostClass [ - - ^ hostClass -] - -{ #category : #accessing } -BlProfileCase >> hostClass: aBlHostClass [ - - hostClass := aBlHostClass -] - -{ #category : #initialization } -BlProfileCase >> initialize [ - - super initialize. - - self resetSpace. -] - -{ #category : #printing } -BlProfileCase >> label [ - - | className ending beginning | - beginning := 'Bl'. - ending := 'ProfileCase'. - - className := self className. - ((className endsWith: ending) and: [ - className beginsWith: beginning ]) ifFalse: [ self notYetImplemented ]. - - ^ (className allButFirst: beginning size) allButLast: ending size -] - -{ #category : #hooks } -BlProfileCase >> newElement [ - "Answer the element under study." - - ^ self subclassResponsibility -] - -{ #category : #API } -BlProfileCase >> openSpace [ - - space root addChild: self newElement. - space root children first requestFocus. - - space - title: self shortDescription; - extent: self spaceExtent; - show -] - -{ #category : #copying } -BlProfileCase >> postCopy [ - - self resetSpace -] - -{ #category : #printing } -BlProfileCase >> printOn: aStream [ - - super printOn: aStream. - aStream - nextPutAll: '('; - print: self label; - nextPutAll: ', '; - print: hostClass label; - nextPutAll: ')'. - -] - -{ #category : #initialization } -BlProfileCase >> resetSpace [ - - space := BlSpace new - -] - -{ #category : #printing } -BlProfileCase >> shortDescription [ - - ^ String streamContents: [ :aStream | - aStream - nextPutAll: self label; - nextPutAll: ' | '; - nextPutAll: hostClass label ] -] - -{ #category : #accessing } -BlProfileCase >> space [ - - ^ space -] - -{ #category : #hooks } -BlProfileCase >> spaceExtent [ - - ^ 800 @ 600 -] diff --git a/src/BlocBenchs-Old/BlSimpleElementProfileCase.class.st b/src/BlocBenchs-Old/BlSimpleElementProfileCase.class.st deleted file mode 100644 index 6b0e9b1..0000000 --- a/src/BlocBenchs-Old/BlSimpleElementProfileCase.class.st +++ /dev/null @@ -1,28 +0,0 @@ -" -I'm a profiling case with an animated BlElement. -" -Class { - #name : #BlSimpleElementProfileCase, - #superclass : #BlFixedDurationProfileCase, - #instVars : [ - 'element' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #hooks } -BlSimpleElementProfileCase >> newElement [ - - ^ element := BlElement new - position: 100 asPoint; - size: 100 asPoint; - border: (BlBorder paint: Color gray width: 4); - addAnimation: (self newSteppingAnimation); - yourself -] - -{ #category : #'instance creation' } -BlSimpleElementProfileCase >> newSteppingAnimation [ - - ^ self subclassResponsibility -] diff --git a/src/BlocBenchs-Old/BlTextEditorProfileCase.class.st b/src/BlocBenchs-Old/BlTextEditorProfileCase.class.st deleted file mode 100644 index 46d2394..0000000 --- a/src/BlocBenchs-Old/BlTextEditorProfileCase.class.st +++ /dev/null @@ -1,92 +0,0 @@ -" -I'm a profiling case where a text editor is scrolled down multiple times. -" -Class { - #name : #BlTextEditorProfileCase, - #superclass : #BlProfileCase, - #instVars : [ - 'editorElement', - 'lapseToWaitBetween', - 'numberOfSimulatedEvents' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #accessing } -BlTextEditorProfileCase >> defaultLapseToWait [ - - ^ 0.5 seconds -] - -{ #category : #accessing } -BlTextEditorProfileCase >> defaultNumberOfSimulatedEvents [ - - ^ 15 -] - -{ #category : #hooks } -BlTextEditorProfileCase >> dispatchEvent [ - - self subclassResponsibility -] - -{ #category : #API } -BlTextEditorProfileCase >> executeBody [ - - | task semaphore | - semaphore := Semaphore new. - task := BlRepeatedTaskAction new. - task delay: self lapseToWaitBetween. - task action: [ - self dispatchEvent. - semaphore signal ]. - space enqueueTask: task. - - "Make this process wait until all events have been dispatched" - self numberOfSimulatedEvents timesRepeat: [ semaphore wait ]. - task stop. - - "Wait a bit more so the last event can be processed" - self lapseToWaitBetween wait -] - -{ #category : #accessing } -BlTextEditorProfileCase >> lapseToWaitBetween [ - - ^ lapseToWaitBetween ifNil: [ lapseToWaitBetween := self defaultLapseToWait ] -] - -{ #category : #accessing } -BlTextEditorProfileCase >> lapseToWaitBetween: aDuration [ - - lapseToWaitBetween := aDuration -] - -{ #category : #hooks } -BlTextEditorProfileCase >> newElement [ - - ^ editorElement := ToAlbum new - text: (String loremIpsum: 20000) asRopedText; - withRowNumbers; - yourself. - -] - -{ #category : #accessing } -BlTextEditorProfileCase >> numberOfSimulatedEvents [ - - ^ numberOfSimulatedEvents ifNil: [ - numberOfSimulatedEvents := self defaultNumberOfSimulatedEvents ] -] - -{ #category : #accessing } -BlTextEditorProfileCase >> numberOfSimulatedEvents: anInteger [ - - numberOfSimulatedEvents := anInteger -] - -{ #category : #hooks } -BlTextEditorProfileCase >> spaceExtent [ - - ^ 500 @ 900 -] diff --git a/src/BlocBenchs-Old/BlTranslateProfileCase.class.st b/src/BlocBenchs-Old/BlTranslateProfileCase.class.st deleted file mode 100644 index ae1d49e..0000000 --- a/src/BlocBenchs-Old/BlTranslateProfileCase.class.st +++ /dev/null @@ -1,16 +0,0 @@ -" -I'm a profiling case with a BlElement that translates during a period of time. -" -Class { - #name : #BlTranslateProfileCase, - #superclass : #BlSimpleElementProfileCase, - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #'instance creation' } -BlTranslateProfileCase >> newSteppingAnimation [ - - ^ (BlTransformAnimation translate: 0@200) - duration: duration; - yourself -] diff --git a/src/BlocBenchs-Old/ToListStressProfileCase.class.st b/src/BlocBenchs-Old/ToListStressProfileCase.class.st deleted file mode 100644 index 4036f12..0000000 --- a/src/BlocBenchs-Old/ToListStressProfileCase.class.st +++ /dev/null @@ -1,33 +0,0 @@ -Class { - #name : #ToListStressProfileCase, - #superclass : #BlFixedDurationProfileCase, - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #examples } -ToListStressProfileCase class >> exampleProfile [ - - [ | case | - case := self new - hostClass: BlOSWindowSDL2Host; - duration: 20 seconds; - yourself. - - (BlProfileRunner newForCase: case) - enableASProfiler; - run; - openMeterReports ] fork -] - -{ #category : #printing } -ToListStressProfileCase >> label [ - - ^ 'Toplo list stress' -] - -{ #category : #hooks } -ToListStressProfileCase >> newElement [ - "Answer the element under study." - - ^ ToListElementStresserWithAdditionalSelecters new tabsPanel -] From 9c28786baa217651ea8d1908c871d53bfeef1bb1 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 22 Nov 2024 12:09:40 +0100 Subject: [PATCH 03/23] Removing duplicated class --- .../BlBAbstractSimpleAnimationCase.class.st | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 src/BlocBenchs-Old/BlBAbstractSimpleAnimationCase.class.st diff --git a/src/BlocBenchs-Old/BlBAbstractSimpleAnimationCase.class.st b/src/BlocBenchs-Old/BlBAbstractSimpleAnimationCase.class.st deleted file mode 100644 index 0e3e75d..0000000 --- a/src/BlocBenchs-Old/BlBAbstractSimpleAnimationCase.class.st +++ /dev/null @@ -1,31 +0,0 @@ -" -I'm a profiling case with an animated BlElement. -" -Class { - #name : #BlBAbstractSimpleAnimationCase, - #superclass : #BlBBlocCase, - #category : #'BlocBenchs-Benchs-Bloc' -} - -{ #category : #running } -BlBAbstractSimpleAnimationCase class >> isAbstract [ - - ^ self == BlBAbstractSimpleAnimationCase -] - -{ #category : #hooks } -BlBAbstractSimpleAnimationCase >> newElement [ - - ^ BlElement new - position: 100 asPoint; - size: 100 asPoint; - border: (BlBorder paint: Color gray width: 4); - addAnimation: (self newSteppingAnimation); - yourself -] - -{ #category : #'instance creation' } -BlBAbstractSimpleAnimationCase >> newSteppingAnimation [ - - ^ self subclassResponsibility -] From 13d7dbd727adf1cfe4f255e285eef7833d05aa1f Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 22 Nov 2024 12:49:01 +0100 Subject: [PATCH 04/23] Migrating meters --- .../BlBBlocBenchRunner.class.st | 8 +- .../BlBFFICounterMeter.class.st | 56 ++++ src/BlocBenchs-Core/BlBFFILogger.class.st | 40 +++ .../BlBSystemProfilerMeter.class.st | 56 ++++ .../BlAndreasSystemProfiler.class.st | 59 ---- src/BlocBenchs-Old/BlFFICounter.class.st | 78 ----- src/BlocBenchs-Old/BlFFILogger.class.st | 39 --- src/BlocBenchs-Old/BlFrameMeter.class.st | 71 ----- src/BlocBenchs-Old/BlMeter.class.st | 60 ---- src/BlocBenchs-Old/BlProfileRunner.class.st | 297 ------------------ .../BlocBenchsSmokeTest.class.st | 6 - 11 files changed, 159 insertions(+), 611 deletions(-) create mode 100644 src/BlocBenchs-Core/BlBFFICounterMeter.class.st create mode 100644 src/BlocBenchs-Core/BlBFFILogger.class.st create mode 100644 src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st delete mode 100644 src/BlocBenchs-Old/BlAndreasSystemProfiler.class.st delete mode 100644 src/BlocBenchs-Old/BlFFICounter.class.st delete mode 100644 src/BlocBenchs-Old/BlFFILogger.class.st delete mode 100644 src/BlocBenchs-Old/BlFrameMeter.class.st delete mode 100644 src/BlocBenchs-Old/BlMeter.class.st delete mode 100644 src/BlocBenchs-Old/BlProfileRunner.class.st diff --git a/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st b/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st index 5252632..e5b3e23 100644 --- a/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st +++ b/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st @@ -10,6 +10,12 @@ Class { #category : #'BlocBenchs-Core' } +{ #category : #adding } +BlBBlocBenchRunner >> addMeter: aBlBMeter [ + + self meters add: aBlBMeter +] + { #category : #'as yet unclassified' } BlBBlocBenchRunner >> cleanUpAfterCase [ @@ -53,7 +59,7 @@ BlBBlocBenchRunner >> duration: aDuration [ { #category : #running } BlBBlocBenchRunner >> meters [ - ^ meters ifNil: [ meters := self defaultMeters ] + ^ meters ifNil: [ meters := self defaultMeters asOrderedCollection ] ] { #category : #'as yet unclassified' } diff --git a/src/BlocBenchs-Core/BlBFFICounterMeter.class.st b/src/BlocBenchs-Core/BlBFFICounterMeter.class.st new file mode 100644 index 0000000..edea30a --- /dev/null +++ b/src/BlocBenchs-Core/BlBFFICounterMeter.class.st @@ -0,0 +1,56 @@ +Class { + #name : #BlBFFICounterMeter, + #superclass : #BlBMeter, + #instVars : [ + 'functionNamesAndCounts' + ], + #category : #'BlocBenchs-Core' +} + +{ #category : #'as yet unclassified' } +BlBFFICounterMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + + aBlBResult + addField: #totalFFICallsPerFrame + title: 'Total FFI Calls per frame' + value: functionNamesAndCounts values sum. + + aBlBResult + addField: #ffiCalls + title: 'FFI Calls per frame' + value: functionNamesAndCounts. + +] + +{ #category : #'as yet unclassified' } +BlBFFICounterMeter >> startMetering: aBlBBlocBenchRunner [ + + "Ensure prepared" + TFLSignal install. + TFLFunctionCounter resetInstance. + + "Really start" + TFLFunctionCounter start. + + aBlBBlocBenchRunner space enableStatistics. +] + +{ #category : #'as yet unclassified' } +BlBFFICounterMeter >> stopMetering: aBlBBlocBenchRunner [ + + "Extract relevant information of the global logger, and reset it." + + | frameCount | + + frameCount := aBlBBlocBenchRunner space spaceStatistics totalFrames. + + functionNamesAndCounts := TFLFunctionCounter instance functionNamesAndCounts. + functionNamesAndCounts := OrderedDictionary newFrom: + (functionNamesAndCounts associations sorted: [ :a :b | + a value > b value ]). + functionNamesAndCounts := functionNamesAndCounts + collect: [ :value | (value / frameCount) asFloat ]. + + TFLSignal uninstall. + TFLFunctionCounter stop; resetInstance. +] diff --git a/src/BlocBenchs-Core/BlBFFILogger.class.st b/src/BlocBenchs-Core/BlBFFILogger.class.st new file mode 100644 index 0000000..fc78172 --- /dev/null +++ b/src/BlocBenchs-Core/BlBFFILogger.class.st @@ -0,0 +1,40 @@ +Class { + #name : #BlBFFILogger, + #superclass : #BlBMeter, + #instVars : [ + 'loggerCopy' + ], + #category : #'BlocBenchs-Core' +} + +{ #category : #'as yet unclassified' } +BlBFFILogger >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + + aBlBResult + addField: #ffiCallsLog + title: 'FFI Calls' + value: loggerCopy +] + +{ #category : #'as yet unclassified' } +BlBFFILogger >> startMetering: aBlBBlocBenchRunner [ + + "Ensure prepared" + TFLSignal install. + TFLCallLogger resetInstance. + TFLCallLogger instance entryCount: 20000. + + "Really start" + TFLCallLogger instance start +] + +{ #category : #'as yet unclassified' } +BlBFFILogger >> stopMetering: aBlBBlocBenchRunner [ + + "Store a copy of the global logger, and reset it." + + loggerCopy := TFLCallLogger instance copy. + + TFLSignal uninstall. + TFLCallLogger stop; resetInstance. +] diff --git a/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st b/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st new file mode 100644 index 0000000..d110ce5 --- /dev/null +++ b/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st @@ -0,0 +1,56 @@ +Class { + #name : #BlBSystemProfilerMeter, + #superclass : #BlBMeter, + #instVars : [ + 'profiler' + ], + #category : #'BlocBenchs-Core' +} + +{ #category : #'as yet unclassified' } +BlBSystemProfilerMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + + | flameGraph | + + flameGraph := profiler saucoAsReport + colorMap: + (SaCategoryPrefixColorMap new + mapPrefixes: #( + 'OSWindow' + 'Alexandrie') + from: Color lightBlue; + mapPrefixes: #( + 'Bloc-Text' + 'BlocHost' + 'Bloc') + from: Color orange; + mapPrefixes: #( + 'Album' + 'Toplo') + from: Color pink; + yourself) . + + aBlBResult + addField: #systemProfilerReport + title: 'System Profiler Report' + value: profiler report. + + aBlBResult + addField: #flameGraph + title: 'Flame Graph' + value: flameGraph. + +] + +{ #category : #'as yet unclassified' } +BlBSystemProfilerMeter >> startMetering: aBlBBlocBenchRunner [ + + profiler := AndreasSystemProfiler new. + profiler startProfiling +] + +{ #category : #'as yet unclassified' } +BlBSystemProfilerMeter >> stopMetering: aBlBBlocBenchRunner [ + + profiler stopProfiling +] diff --git a/src/BlocBenchs-Old/BlAndreasSystemProfiler.class.st b/src/BlocBenchs-Old/BlAndreasSystemProfiler.class.st deleted file mode 100644 index 485ce4c..0000000 --- a/src/BlocBenchs-Old/BlAndreasSystemProfiler.class.st +++ /dev/null @@ -1,59 +0,0 @@ -Class { - #name : #BlAndreasSystemProfiler, - #superclass : #BlMeter, - #instVars : [ - 'profiler' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #API } -BlAndreasSystemProfiler >> reportsAsPagesUsing: aBuilder [ - - ^ { - - - SpNotebookPage title: 'Report as String' provider: [ - (aBuilder newText - text: profiler report; - yourself) ]. - - - SpNotebookPage title: 'Flame Graph' provider: [ - - profiler saucoAsReport - colorMap: - (SaCategoryPrefixColorMap new - mapPrefixes: #( - 'OSWindow' - 'Alexandrie') - from: Color lightBlue; - mapPrefixes: #( - 'Bloc-Text' - 'BlocHost' - 'Bloc') - from: Color orange; - mapPrefixes: #( - 'Album' - 'Toplo') - from: Color pink; - yourself) ; - inspectionForFlameGraph: aBuilder. - - ] - } - -] - -{ #category : #API } -BlAndreasSystemProfiler >> startMetering [ - - profiler := AndreasSystemProfiler new. - profiler startProfiling -] - -{ #category : #API } -BlAndreasSystemProfiler >> stopMetering [ - - profiler stopProfiling -] diff --git a/src/BlocBenchs-Old/BlFFICounter.class.st b/src/BlocBenchs-Old/BlFFICounter.class.st deleted file mode 100644 index e238016..0000000 --- a/src/BlocBenchs-Old/BlFFICounter.class.st +++ /dev/null @@ -1,78 +0,0 @@ -Class { - #name : #BlFFICounter, - #superclass : #BlMeter, - #instVars : [ - 'functionNamesAndCounts' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #API } -BlFFICounter >> reportAsStringOn: aStream [ - - aStream - << 'FFI Call Stats'; lf; - << self reportCallStatsAsString; lf. -] - -{ #category : #API } -BlFFICounter >> reportCallStatsAsString [ - - ^ String streamContents: [ :stream | - stream - << 'Average: '; - << (functionNamesAndCounts values sum printShowingDecimalPlaces: 2); - << ' calls/frame'; lf. - ] -] - -{ #category : #API } -BlFFICounter >> reportsAsPagesUsing: aBuilder [ - - ^ { - (SpNotebookPage - title: 'FFI Call Stats' - provider: [ - aBuilder newText text: self reportCallStatsAsString; yourself ]). - (SpNotebookPage - title: 'FFI Calls (Avg. per Frame)' - provider: [ - "Too many decimal places, else." - (functionNamesAndCounts associations - collect: [ :each | each key -> (each value printShowingDecimalPlaces: 1) ]) asOrderedDictionary - inspectionItems: aBuilder ]) - } -] - -{ #category : #API } -BlFFICounter >> startMetering [ - - "Ensure prepared" - TFLSignal install. - TFLFunctionCounter resetInstance. - - "Really start" - TFLFunctionCounter start. - - case space enableStatistics. -] - -{ #category : #API } -BlFFICounter >> stopMetering [ - - "Extract relevant information of the global logger, and reset it." - - | frameCount | - - frameCount := case space spaceStatistics totalFrames. - - functionNamesAndCounts := TFLFunctionCounter instance functionNamesAndCounts. - functionNamesAndCounts := OrderedDictionary newFrom: - (functionNamesAndCounts associations sorted: [ :a :b | - a value > b value ]). - functionNamesAndCounts := functionNamesAndCounts - collect: [ :value | (value / frameCount) asFloat ]. - - TFLSignal uninstall. - TFLFunctionCounter stop; resetInstance. -] diff --git a/src/BlocBenchs-Old/BlFFILogger.class.st b/src/BlocBenchs-Old/BlFFILogger.class.st deleted file mode 100644 index 1297aee..0000000 --- a/src/BlocBenchs-Old/BlFFILogger.class.st +++ /dev/null @@ -1,39 +0,0 @@ -Class { - #name : #BlFFILogger, - #superclass : #BlMeter, - #instVars : [ - 'loggerCopy' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #API } -BlFFILogger >> reportsAsPagesUsing: aBuilder [ - - ^ { (SpNotebookPage - title: 'FFI Recorded Calls' - provider: [ - aBuilder instantiate: TFLCallsPresenter on: loggerCopy ]) } -] - -{ #category : #API } -BlFFILogger >> startMetering [ - - "Ensure prepared" - TFLSignal install. - TFLCallLogger resetInstance. - TFLCallLogger instance entryCount: 20000. - - "Really start" - TFLCallLogger instance start -] - -{ #category : #API } -BlFFILogger >> stopMetering [ - "Store a copy of the global logger, and reset it." - - loggerCopy := TFLCallLogger instance copy. - - TFLSignal uninstall. - TFLCallLogger stop; resetInstance. -] diff --git a/src/BlocBenchs-Old/BlFrameMeter.class.st b/src/BlocBenchs-Old/BlFrameMeter.class.st deleted file mode 100644 index d4f1556..0000000 --- a/src/BlocBenchs-Old/BlFrameMeter.class.st +++ /dev/null @@ -1,71 +0,0 @@ -Class { - #name : #BlFrameMeter, - #superclass : #BlMeter, - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #printing } -BlFrameMeter >> reportAsStringOn: stream [ - - | stats fpsSamples | - - stats := case space spaceStatistics. - fpsSamples := stats fpsSamples allButFirst collect: [:e | e second]. - - stream - << 'Number of samples:'; - lf; - tab; - print: fpsSamples size; - lf. - - stream - << 'Frame count:'; - lf; - tab; - print: stats totalFrames; - lf. - - fpsSamples ifEmpty: [ ^ self ]. - - stream - << 'FPS mean and error margin (90% confidence level):'; - lf; - tab; - << (MeanConfidenceIntervalPrinter new print: fpsSamples); - lf. - - stream << 'FPS samples:'; lf. - fpsSamples withIndexDo: [ :fps :index | - stream - tab; - print: index; - << '-'; - print: index + 1; - << ': '; - << (fps printShowingDecimalPlaces: 1); - << ' fps'; - lf ] - -] - -{ #category : #API } -BlFrameMeter >> reportsAsPagesUsing: aBuilder [ - - ^ { (SpNotebookPage title: 'Frame Report' provider: [ - aBuilder newText - text: self reportAsString; - yourself ]) } -] - -{ #category : #API } -BlFrameMeter >> startMetering [ - - case space enableStatistics -] - -{ #category : #API } -BlFrameMeter >> stopMetering [ - - -] diff --git a/src/BlocBenchs-Old/BlMeter.class.st b/src/BlocBenchs-Old/BlMeter.class.st deleted file mode 100644 index a91224e..0000000 --- a/src/BlocBenchs-Old/BlMeter.class.st +++ /dev/null @@ -1,60 +0,0 @@ -" -I represent a meter in the context of a Bloc profile. - -API: - - startMetering - - stopMetering - -Collaborators: - - case: the case under study, which may be needed by the meter. -" -Class { - #name : #BlMeter, - #superclass : #Object, - #instVars : [ - 'case' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #accessing } -BlMeter >> case [ - - ^ case -] - -{ #category : #accessing } -BlMeter >> case: aCase [ - - case := aCase -] - -{ #category : #printing } -BlMeter >> reportAsString [ - - ^ String streamContents: [ :stream | self reportAsStringOn: stream ] -] - -{ #category : #printing } -BlMeter >> reportAsStringOn: aStream [ - - self subclassResponsibility -] - -{ #category : #API } -BlMeter >> reportsAsPagesUsing: aBuilder [ - - self subclassResponsibility -] - -{ #category : #API } -BlMeter >> startMetering [ - - self subclassResponsibility -] - -{ #category : #API } -BlMeter >> stopMetering [ - - self subclassResponsibility -] diff --git a/src/BlocBenchs-Old/BlProfileRunner.class.st b/src/BlocBenchs-Old/BlProfileRunner.class.st deleted file mode 100644 index 98fc1fd..0000000 --- a/src/BlocBenchs-Old/BlProfileRunner.class.st +++ /dev/null @@ -1,297 +0,0 @@ -" -I'm in charge of profiling cases. - -A case can be profiled in two ways: -- #run, profiles the body. -- #runOnOpen, profiles only the opening. - -See my class-side for an example. - -" -Class { - #name : #BlProfileRunner, - #superclass : #Object, - #instVars : [ - 'case', - 'meters' - ], - #category : #'BlocBenchs-Old-ProfileCases' -} - -{ #category : #examples } -BlProfileRunner class >> casesToProfile [ - - ^ { BlBoidsProfileCase new } -] - -{ #category : #examples } -BlProfileRunner class >> exampleAll [ - - | cases runners | - cases := self casesToProfile. - runners := self hostClassesToProfile flatCollect: [ :eachHostClass | - cases collect: [ :eachCase | - | case | - case := eachCase copy - hostClass: eachHostClass; - yourself. - - (BlProfileRunner newForCase: case) - enableFPS; - enableFFILogger; - enableFFICounter; - enableASProfiler; - yourself - - ] ]. - - [ runners do: #run. - runners do: #openMeterReports ] fork. - -] - -{ #category : #examples } -BlProfileRunner class >> exampleMinimalFPS [ - - [ | case | - case := BlBoidsProfileCase new - hostClass: BlOSWindowSDL2Host; - duration: 7 seconds; - yourself. - - (BlProfileRunner newForCase: case) - enableFPS; - run; - openMeterReports ] fork -] - -{ #category : #examples } -BlProfileRunner class >> exampleOnlyFFI [ - - | cases runners | - cases := self casesToProfile. - runners := self hostClassesToProfile flatCollect: [ :eachHostClass | - cases collect: [ :eachCase | - | case | - case := eachCase copy - hostClass: eachHostClass; - yourself. - - (BlProfileRunner newForCase: case) - enableFFICounter; - enableFFILogger; - yourself - - ] ]. - - [ runners do: #run. - runners do: #openMeterReports ] fork - -] - -{ #category : #examples } -BlProfileRunner class >> exampleOnlyFPS [ - - | cases runners | - cases := self casesToProfile. - runners := self hostClassesToProfile flatCollect: [ :eachHostClass | - cases collect: [ :eachCase | - | case | - case := eachCase copy - hostClass: eachHostClass; - yourself. - - (BlProfileRunner newForCase: case) - enableFPS; - yourself - - ] ]. - - [ runners do: #run. - runners do: #openMeterReports ] fork. - -] - -{ #category : #examples } -BlProfileRunner class >> exampleOnlyFlameGraph [ - - | cases runners | - cases := self casesToProfile. - runners := self hostClassesToProfile flatCollect: [ :eachHostClass | - cases collect: [ :eachCase | - | case | - case := eachCase copy - hostClass: eachHostClass; - yourself. - - (BlProfileRunner newForCase: case) - enableASProfiler; - yourself - - ] ]. - - [ runners do: #run. - runners do: #openMeterReports ] fork. - -] - -{ #category : #examples } -BlProfileRunner class >> hostClassesToProfile [ - - ^ { BlOSWindowSDL2Host "BlMorphicWindowHost" } -] - -{ #category : #'instance creation' } -BlProfileRunner class >> newForCase: aProfileCase [ - - ^ self new - case: aProfileCase; - yourself -] - -{ #category : #accessing } -BlProfileRunner >> addMeter: aMeter [ - - meters add: aMeter -] - -{ #category : #accessing } -BlProfileRunner >> case [ - - ^ case -] - -{ #category : #accessing } -BlProfileRunner >> case: aProfileCase [ - - case := aProfileCase -] - -{ #category : #convenience } -BlProfileRunner >> enableASProfiler [ - - self addMeter: BlAndreasSystemProfiler new -] - -{ #category : #convenience } -BlProfileRunner >> enableFFICounter [ - - self addMeter: BlFFICounter new -] - -{ #category : #convenience } -BlProfileRunner >> enableFFILogger [ - - self addMeter: BlFFILogger new -] - -{ #category : #convenience } -BlProfileRunner >> enableFPS [ - - self addMeter: BlFrameMeter new -] - -{ #category : #initialization } -BlProfileRunner >> initialize [ - - super initialize. - - meters := OrderedCollection new. -] - -{ #category : #accessing } -BlProfileRunner >> meters [ - - ^ meters -] - -{ #category : #API } -BlProfileRunner >> openMeterReports [ - - | notebook meterPresenters | - notebook := SpNotebookPresenter new. - meterPresenters := meters flatCollect: [ :each | - each reportsAsPagesUsing: notebook ]. - - meterPresenters do: [ :each | notebook addPage: each ]. - - notebook - addPageTitle: 'Raw' - provider: [ Smalltalk tools inspector onObject: self ]. - - notebook open - title: case shortDescription; - extent: 800 @ 600 -] - -{ #category : #printing } -BlProfileRunner >> printOn: aStream [ - - super printOn: aStream. - aStream - nextPut: $(; - print: case; - nextPut: $) - -] - -{ #category : #API } -BlProfileRunner >> reportMeterReportsOnStdout [ - - | logStream | - logStream := Stdio stdout. - - logStream nextPutAll: case shortDescription; lf. - - meters do: [ :each | - logStream - nextPutAll: each asString; - lf; - nextPutAll: each reportAsString; - lf ]. - - logStream nextPutAll: '---'; lf. -] - -{ #category : #running } -BlProfileRunner >> run [ - "Profile the body of the case." - - self withBlocParametersDo: [ - case openSpace. - [ self withStartedMetersDo: [ case executeBody ] ] - ensure: [ case closeSpace ] ] -] - -{ #category : #running } -BlProfileRunner >> runOnOpen [ - "Profile the opening of the case." - - self withBlocParametersDo: [ - [ self withStartedMetersDo: [ case openSpace ] ] - ensure: [ case closeSpace ] ] - -] - -{ #category : #private } -BlProfileRunner >> withBlocParametersDo: aBlockClosure [ - - case space host: case hostClass new. - aBlockClosure value. - -] - -{ #category : #private } -BlProfileRunner >> withStartedMetersDo: aBlockClosure [ - - meters do: [ :each | - each - case: case; - startMetering ]. - - aBlockClosure ensure: [ - - meters reverseDo: [ :each | - each stopMetering ] ] - -] diff --git a/src/BlocBenchs-Tests/BlocBenchsSmokeTest.class.st b/src/BlocBenchs-Tests/BlocBenchsSmokeTest.class.st index 1d43563..e576666 100644 --- a/src/BlocBenchs-Tests/BlocBenchsSmokeTest.class.st +++ b/src/BlocBenchs-Tests/BlocBenchsSmokeTest.class.st @@ -30,12 +30,6 @@ BlocBenchsSmokeTest >> testBlMouseMoveBenchmark [ BlMouseMoveBenchmark exampleRun ] -{ #category : #tests } -BlocBenchsSmokeTest >> testBlProfileRunner [ - - BlProfileRunner exampleAll -] - { #category : #tests } BlocBenchsSmokeTest >> testPCBenchmarker1 [ From a8ca9669eae337cbc98b9ab306ab8c26dca2d5ce Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Tue, 26 Nov 2024 17:40:53 +0100 Subject: [PATCH 05/23] - Adding matrix for the benchs - Adding Raw Benchs - Migrating Benchs --- .../BlBBoidsSkyCase.class.st | 29 ++++ .../BlBBoidsSkyUsingCustomDrawCase.class.st | 11 -- ...SkyUsingCustomGeometryElementCase.class.st | 11 -- ...BBoidsSkyUsingGeometryElementCase.class.st | 11 -- .../BlBBoxWindmillBlocCase.class.st | 47 ++++++ ...BlBBoxWindmillCompositionRawCase.class.st} | 87 ++++++----- .../BlBClearCanvasRawCase.class.st | 11 ++ .../BlBCompositionCase.class.st} | 60 +++----- ...ntStresserWithAdditionalSelecters.class.st | 7 +- .../TBlBBoxWindmillLogic.trait.st | 62 ++++++++ .../TBlBCompositionLogic.trait.st | 35 +++++ .../BlAllocationsMeter.class.st | 2 +- .../BlBAbstractBenchRunner.class.st | 95 ++++++++++++ .../BlBBlocBenchRunner.class.st | 82 ++-------- src/BlocBenchs-Core/BlBBlocCase.class.st | 2 +- ...lass.st => BlBBlocRenderingMeter.class.st} | 10 +- src/BlocBenchs-Core/BlBCase.class.st | 66 +++++++- src/BlocBenchs-Core/BlBError.class.st | 29 ++++ .../BlBFFICounterMeter.class.st | 8 +- src/BlocBenchs-Core/BlBFFILogger.class.st | 2 +- src/BlocBenchs-Core/BlBMeter.class.st | 7 +- .../BlBRawBenchRunner.class.st | 131 ++++++++++++++++ src/BlocBenchs-Core/BlBRawCase.class.st | 145 ++++++++++++++++++ .../BlBRawRenderingMeter.class.st | 50 ++++++ src/BlocBenchs-Core/BlBResult.class.st | 2 +- .../BlBSystemProfilerMeter.class.st | 2 +- src/BlocBenchs-Core/BlBTimeMeter.class.st | 2 +- .../BlBCompositionCase.class.st | 70 +++++++++ src/BlocBenchs-FPS/PCBenchmarker.class.st | 43 +----- .../PCBoxWindmillBenchCase.class.st | 114 -------------- .../PCBoxWindmillWindow.class.st | 36 ----- .../PCCompositionDisabledBenchCase.class.st | 16 -- .../PCCompositionEnabledBenchCase.class.st | 17 -- 33 files changed, 883 insertions(+), 419 deletions(-) create mode 100644 src/BlocBenchs-Benchs/BlBBoidsSkyCase.class.st delete mode 100644 src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st delete mode 100644 src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomGeometryElementCase.class.st delete mode 100644 src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBBoxWindmillBlocCase.class.st rename src/{BlocBenchs-FPS/PCBoxWindmillCompositingWindow.class.st => BlocBenchs-Benchs/BlBBoxWindmillCompositionRawCase.class.st} (54%) create mode 100644 src/BlocBenchs-Benchs/BlBClearCanvasRawCase.class.st rename src/{BlocBenchs-FPS/PCCompositionBenchCase.class.st => BlocBenchs-Benchs/BlBCompositionCase.class.st} (50%) create mode 100644 src/BlocBenchs-Benchs/TBlBBoxWindmillLogic.trait.st create mode 100644 src/BlocBenchs-Benchs/TBlBCompositionLogic.trait.st create mode 100644 src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st rename src/BlocBenchs-Core/{BlBRenderingMeter.class.st => BlBBlocRenderingMeter.class.st} (76%) create mode 100644 src/BlocBenchs-Core/BlBError.class.st create mode 100644 src/BlocBenchs-Core/BlBRawBenchRunner.class.st create mode 100644 src/BlocBenchs-Core/BlBRawCase.class.st create mode 100644 src/BlocBenchs-Core/BlBRawRenderingMeter.class.st create mode 100644 src/BlocBenchs-FPS/BlBCompositionCase.class.st delete mode 100644 src/BlocBenchs-FPS/PCBoxWindmillBenchCase.class.st delete mode 100644 src/BlocBenchs-FPS/PCBoxWindmillWindow.class.st delete mode 100644 src/BlocBenchs-FPS/PCCompositionDisabledBenchCase.class.st delete mode 100644 src/BlocBenchs-FPS/PCCompositionEnabledBenchCase.class.st diff --git a/src/BlocBenchs-Benchs/BlBBoidsSkyCase.class.st b/src/BlocBenchs-Benchs/BlBBoidsSkyCase.class.st new file mode 100644 index 0000000..1a2db71 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBBoidsSkyCase.class.st @@ -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 +] diff --git a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st deleted file mode 100644 index 91a02c2..0000000 --- a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomDrawCase.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #BlBBoidsSkyUsingCustomDrawCase, - #superclass : #BlBBlocCase, - #category : #'BlocBenchs-Benchs-Bloc' -} - -{ #category : #'instance creation' } -BlBBoidsSkyUsingCustomDrawCase >> newElement [ - - ^ BoidsCustomDrawSkyElement new -] diff --git a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomGeometryElementCase.class.st b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomGeometryElementCase.class.st deleted file mode 100644 index 1a545c2..0000000 --- a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingCustomGeometryElementCase.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #BlBBoidsSkyUsingCustomGeometryElementCase, - #superclass : #BlBBlocCase, - #category : #'BlocBenchs-Benchs-Bloc' -} - -{ #category : #'instance creation' } -BlBBoidsSkyUsingCustomGeometryElementCase >> newElement [ - - ^ BoidCustomGeometrySkyElement new -] diff --git a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st b/src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st deleted file mode 100644 index 6b844a8..0000000 --- a/src/BlocBenchs-Benchs/BlBBoidsSkyUsingGeometryElementCase.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #BlBBoidsSkyUsingGeometryElementCase, - #superclass : #BlBBlocCase, - #category : #'BlocBenchs-Benchs-Bloc' -} - -{ #category : #'instance creation' } -BlBBoidsSkyUsingGeometryElementCase >> newElement [ - - ^ BoidsSkyUsingGeometryElement new -] diff --git a/src/BlocBenchs-Benchs/BlBBoxWindmillBlocCase.class.st b/src/BlocBenchs-Benchs/BlBBoxWindmillBlocCase.class.st new file mode 100644 index 0000000..a382999 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBBoxWindmillBlocCase.class.st @@ -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 +] diff --git a/src/BlocBenchs-FPS/PCBoxWindmillCompositingWindow.class.st b/src/BlocBenchs-Benchs/BlBBoxWindmillCompositionRawCase.class.st similarity index 54% rename from src/BlocBenchs-FPS/PCBoxWindmillCompositingWindow.class.st rename to src/BlocBenchs-Benchs/BlBBoxWindmillCompositionRawCase.class.st index fc92cba..d7b62c6 100644 --- a/src/BlocBenchs-FPS/PCBoxWindmillCompositingWindow.class.st +++ b/src/BlocBenchs-Benchs/BlBBoxWindmillCompositionRawCase.class.st @@ -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. @@ -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. @@ -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 @@ -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 -] diff --git a/src/BlocBenchs-Benchs/BlBClearCanvasRawCase.class.st b/src/BlocBenchs-Benchs/BlBClearCanvasRawCase.class.st new file mode 100644 index 0000000..35670ff --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBClearCanvasRawCase.class.st @@ -0,0 +1,11 @@ +Class { + #name : #BlBClearCanvasRawCase, + #superclass : #BlBRawCase, + #category : #'BlocBenchs-Benchs-Raw' +} + +{ #category : #'as yet unclassified' } +BlBClearCanvasRawCase >> drawOnCairoSurface [ + + self clearCairoSurface +] diff --git a/src/BlocBenchs-FPS/PCCompositionBenchCase.class.st b/src/BlocBenchs-Benchs/BlBCompositionCase.class.st similarity index 50% rename from src/BlocBenchs-FPS/PCCompositionBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBCompositionCase.class.st index a5fae86..a9d4ed2 100644 --- a/src/BlocBenchs-FPS/PCCompositionBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBCompositionCase.class.st @@ -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. @@ -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); @@ -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 ] diff --git a/src/BlocBenchs-Benchs/BlBToploListElementStresserWithAdditionalSelecters.class.st b/src/BlocBenchs-Benchs/BlBToploListElementStresserWithAdditionalSelecters.class.st index ec68628..9562e5e 100644 --- a/src/BlocBenchs-Benchs/BlBToploListElementStresserWithAdditionalSelecters.class.st +++ b/src/BlocBenchs-Benchs/BlBToploListElementStresserWithAdditionalSelecters.class.st @@ -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' } diff --git a/src/BlocBenchs-Benchs/TBlBBoxWindmillLogic.trait.st b/src/BlocBenchs-Benchs/TBlBBoxWindmillLogic.trait.st new file mode 100644 index 0000000..310c918 --- /dev/null +++ b/src/BlocBenchs-Benchs/TBlBBoxWindmillLogic.trait.st @@ -0,0 +1,62 @@ +Trait { + #name : #TBlBBoxWindmillLogic, + #category : #'BlocBenchs-Benchs' +} + +{ #category : #model } +TBlBBoxWindmillLogic >> backgroundColor [ + + ^ Color black +] + +{ #category : #model } +TBlBBoxWindmillLogic >> boxBorderColor [ + + ^ Color blue muchDarker alpha: 0.5 +] + +{ #category : #model } +TBlBBoxWindmillLogic >> boxBorderWidth [ + + ^ 10 +] + +{ #category : #model } +TBlBBoxWindmillLogic >> boxColor [ + + ^ Color white +] + +{ #category : #model } +TBlBBoxWindmillLogic >> boxExtent [ + + ^ 140 @ 40 +] + +{ #category : #model } +TBlBBoxWindmillLogic >> boxPositions [ + "Answer the logical positions for the boxes" + + ^ self boxPositions: 1@1 +] + +{ #category : #model } +TBlBBoxWindmillLogic >> boxPositions: aDeviceScale [ + "Answer the positions for the boxes in the pixel space" + + ^ (0 to: self logicalExtent x * aDeviceScale x by: 50 * aDeviceScale x) flatCollect: [ :x | + (0 to: self logicalExtent y * aDeviceScale y by: 50 * aDeviceScale y) collect: [ :y | + (x @ y) - (self boxExtent * aDeviceScale / 2) ] ] +] + +{ #category : #model } +TBlBBoxWindmillLogic >> boxRotationInDegreesWithPosition: position elapsedMS: elapsedMS [ + + ^ ((position x + position y + (elapsedMS/50.0) ) degreesToRadians * 1.95) radiansToDegrees +] + +{ #category : #accessing } +TBlBBoxWindmillLogic >> logicalExtent [ + + ^ 800 asPoint +] diff --git a/src/BlocBenchs-Benchs/TBlBCompositionLogic.trait.st b/src/BlocBenchs-Benchs/TBlBCompositionLogic.trait.st new file mode 100644 index 0000000..f997786 --- /dev/null +++ b/src/BlocBenchs-Benchs/TBlBCompositionLogic.trait.st @@ -0,0 +1,35 @@ +Trait { + #name : #TBlBCompositionLogic, + #category : #'BlocBenchs-Benchs' +} + +{ #category : #accessing } +TBlBCompositionLogic >> figureExtent [ + + ^ 25 asPoint +] + +{ #category : #accessing } +TBlBCompositionLogic >> layerExtent [ + + ^ self logicalExtent / 1.5 +] + +{ #category : #accessing } +TBlBCompositionLogic >> logicalExtent [ + + ^ 700 @ 700 +] + +{ #category : #hook } +TBlBCompositionLogic >> nextLocation: random [ + + ^ (random nextInteger: self layerExtent x - self figureExtent x) + @ (random nextInteger: self layerExtent y - self figureExtent y) +] + +{ #category : #accessing } +TBlBCompositionLogic >> numberOfFigures [ + + ^ 5000 +] diff --git a/src/BlocBenchs-Core/BlAllocationsMeter.class.st b/src/BlocBenchs-Core/BlAllocationsMeter.class.st index 0a800a2..7c10411 100644 --- a/src/BlocBenchs-Core/BlAllocationsMeter.class.st +++ b/src/BlocBenchs-Core/BlAllocationsMeter.class.st @@ -5,7 +5,7 @@ Class { 'initialAllocationBytes', 'finalAllocationBytes' ], - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } { #category : #'as yet unclassified' } diff --git a/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st b/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st new file mode 100644 index 0000000..1e5eca9 --- /dev/null +++ b/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st @@ -0,0 +1,95 @@ +Class { + #name : #BlBAbstractBenchRunner, + #superclass : #Object, + #instVars : [ + 'result', + 'meters', + 'duration' + ], + #category : #'BlocBenchs-Core-Core' +} + +{ #category : #adding } +BlBAbstractBenchRunner >> addMeter: aBlBMeter [ + + self meters add: aBlBMeter +] + +{ #category : #'as yet unclassified' } +BlBAbstractBenchRunner >> cleanUpAfterCase: aBlBCase [ + ^ self subclassResponsibility +] + +{ #category : #running } +BlBAbstractBenchRunner >> defaultMeters [ + + ^ { + BlBTimeMeter new. + BlAllocationsMeter new. + BlBFFICounterMeter new } +] + +{ #category : #'as yet unclassified' } +BlBAbstractBenchRunner >> doRun: aBlBBlocCase [ + ^ self subclassResponsibility +] + +{ #category : #accessing } +BlBAbstractBenchRunner >> duration: aDuration [ + duration := aDuration +] + +{ #category : #running } +BlBAbstractBenchRunner >> meters [ + + ^ meters ifNil: [ meters := self defaultMeters asOrderedCollection ] +] + +{ #category : #running } +BlBAbstractBenchRunner >> reportMeters [ + + self meters do: [:e | e reportResultsFrom: self in: result]. +] + +{ #category : #running } +BlBAbstractBenchRunner >> runCase: aCase [ + + result := BlBResult new. + result initializeFrom: aCase. + + ^ [ + self prepareBeforeRun: aCase. + self setDuration: aCase. + self startMeters. + self doRun: aCase. + self stopMeters. + self reportMeters. + result + ] ensure: [ self cleanUpAfterCase: aCase ] +] + +{ #category : #running } +BlBAbstractBenchRunner >> setDuration: aCase [ + + duration + ifNotNil: [ aCase duration: duration ] + ifNil: [ duration := aCase duration ]. + +] + +{ #category : #running } +BlBAbstractBenchRunner >> startMeters [ + + self meters do: [:e | e startMetering: self]. +] + +{ #category : #running } +BlBAbstractBenchRunner >> stopMeters [ + + self meters reverse do: [:e | e stopMetering: self]. +] + +{ #category : #'as yet unclassified' } +BlBAbstractBenchRunner >> totalFrames [ + ^ self subclassResponsibility +] diff --git a/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st b/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st index e5b3e23..f74f12d 100644 --- a/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st +++ b/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st @@ -1,23 +1,14 @@ Class { #name : #BlBBlocBenchRunner, - #superclass : #Object, + #superclass : #BlBAbstractBenchRunner, #instVars : [ - 'space', - 'result', - 'meters', - 'duration' + 'space' ], - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } -{ #category : #adding } -BlBBlocBenchRunner >> addMeter: aBlBMeter [ - - self meters add: aBlBMeter -] - -{ #category : #'as yet unclassified' } -BlBBlocBenchRunner >> cleanUpAfterCase [ +{ #category : #running } +BlBBlocBenchRunner >> cleanUpAfterCase: aBlBCase [ space ifNil: [ ^ self ]. @@ -29,19 +20,12 @@ BlBBlocBenchRunner >> cleanUpAfterCase [ { #category : #running } BlBBlocBenchRunner >> defaultMeters [ - ^ { - BlBTimeMeter new. - BlBRenderingMeter new. - BlAllocationsMeter new } + ^ super defaultMeters , { BlBBlocRenderingMeter new } ] -{ #category : #'as yet unclassified' } +{ #category : #running } BlBBlocBenchRunner >> doRun: aBlBBlocCase [ - - duration - ifNotNil: [ aBlBBlocCase duration: duration ] - ifNil: [ duration := aBlBBlocCase duration ]. - + space extent: aBlBBlocCase spaceExtent. space root addChild: aBlBBlocCase newElement. space root children first requestFocus. @@ -51,43 +35,11 @@ BlBBlocBenchRunner >> doRun: aBlBBlocCase [ ] -{ #category : #accessing } -BlBBlocBenchRunner >> duration: aDuration [ - duration := aDuration -] - { #category : #running } -BlBBlocBenchRunner >> meters [ - - ^ meters ifNil: [ meters := self defaultMeters asOrderedCollection ] -] - -{ #category : #'as yet unclassified' } -BlBBlocBenchRunner >> prepareBeforeRun [ +BlBBlocBenchRunner >> prepareBeforeRun: aBlBCase [ - space := BlSpace new -] - -{ #category : #running } -BlBBlocBenchRunner >> reportMeters [ - - self meters do: [:e | e reportResultsFrom: self in: result]. -] - -{ #category : #running } -BlBBlocBenchRunner >> runCase: aCase [ - - result := BlBResult new. - result initializeFrom: aCase. - - ^ [ - self prepareBeforeRun. - self startMeters. - self doRun: aCase. - self stopMeters. - self reportMeters. - result - ] ensure: [ self cleanUpAfterCase ] + space := BlSpace new. + space enableStatistics. ] { #category : #accessing } @@ -95,14 +47,8 @@ BlBBlocBenchRunner >> space [ ^ space ] -{ #category : #running } -BlBBlocBenchRunner >> startMeters [ - - self meters do: [:e | e startMetering: self]. -] - -{ #category : #running } -BlBBlocBenchRunner >> stopMeters [ +{ #category : #accessing } +BlBBlocBenchRunner >> totalFrames [ - self meters reverse do: [:e | e stopMetering: self]. + ^ self space spaceStatistics totalFrames ] diff --git a/src/BlocBenchs-Core/BlBBlocCase.class.st b/src/BlocBenchs-Core/BlBBlocCase.class.st index 1b3558a..b1499a3 100644 --- a/src/BlocBenchs-Core/BlBBlocCase.class.st +++ b/src/BlocBenchs-Core/BlBBlocCase.class.st @@ -1,7 +1,7 @@ Class { #name : #BlBBlocCase, #superclass : #BlBCase, - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } { #category : #running } diff --git a/src/BlocBenchs-Core/BlBRenderingMeter.class.st b/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st similarity index 76% rename from src/BlocBenchs-Core/BlBRenderingMeter.class.st rename to src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st index bc3a522..e412641 100644 --- a/src/BlocBenchs-Core/BlBRenderingMeter.class.st +++ b/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st @@ -1,11 +1,11 @@ Class { - #name : #BlBRenderingMeter, + #name : #BlBBlocRenderingMeter, #superclass : #BlBMeter, - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } { #category : #'as yet unclassified' } -BlBRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ +BlBBlocRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ | stats fpsSamples | stats := aBlBBlocBenchRunner space spaceStatistics. @@ -39,13 +39,13 @@ BlBRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ ] { #category : #'as yet unclassified' } -BlBRenderingMeter >> startMetering: aBlBBlocBenchRunner [ +BlBBlocRenderingMeter >> startMetering: aBlBBlocBenchRunner [ aBlBBlocBenchRunner space enableStatistics ] { #category : #'as yet unclassified' } -BlBRenderingMeter >> stopMetering: aBlBBlocBenchRunner [ +BlBBlocRenderingMeter >> stopMetering: aBlBBlocBenchRunner [ ] diff --git a/src/BlocBenchs-Core/BlBCase.class.st b/src/BlocBenchs-Core/BlBCase.class.st index effe21c..24c8a6e 100644 --- a/src/BlocBenchs-Core/BlBCase.class.st +++ b/src/BlocBenchs-Core/BlBCase.class.st @@ -3,22 +3,55 @@ Class { #superclass : #Object, #instVars : [ 'runner', - 'result', - 'duration' + 'duration', + 'label' ], - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } +{ #category : #benchmarking } +BlBCase class >> benchMatrix [ + + ^ ParametrizedTestMatrix new +] + +{ #category : #running } +BlBCase class >> benchSuite [ + + | benchClasses | + + benchClasses := self withAllSubclasses reject: [ :e | e isAbstract ]. + ^ benchClasses flatCollect: [ :aClass | aClass possibleBenchCases ] + +] + { #category : #running } BlBCase class >> isAbstract [ ^ self == BlBCase ] +{ #category : #'as yet unclassified' } +BlBCase class >> possibleBenchCases [ + + | matrix | + + matrix := self benchMatrix. + matrix isEmpty ifTrue: [ ^ { self new } ]. + + ^ matrix expandMatrix collect: [ :aCaseDefinition | + | aBenchCase | + aBenchCase := self new. + aCaseDefinition do: [ :anExpandedParameter | + anExpandedParameter applyTo: aBenchCase]. + aBenchCase] +] + { #category : #running } BlBCase class >> run [ - ^ self new run + ^ self benchSuite collect: [ :e | e run ] + ] { #category : #'accessing - defaults' } @@ -42,7 +75,30 @@ BlBCase >> duration: aDuration [ { #category : #accessing } BlBCase >> label [ - ^ self class name + ^ label ifNil: [ self class name ] +] + +{ #category : #accessing } +BlBCase >> label: aValue [ + + label := aValue +] + +{ #category : #'instance creation' } +BlBCase >> newColorGenerator [ + + ^ Generator on: [ :generator | + | nextIndex wheel| + nextIndex := 1. + wheel := Color wheel: 20. + [ generator yield: (wheel at: nextIndex). + nextIndex := (nextIndex + 1) \\ wheel size + 1 ] repeat ] +] + +{ #category : #'instance creation' } +BlBCase >> newRandom [ + + ^ Random seed: 1 ] { #category : #running } diff --git a/src/BlocBenchs-Core/BlBError.class.st b/src/BlocBenchs-Core/BlBError.class.st new file mode 100644 index 0000000..866bacf --- /dev/null +++ b/src/BlocBenchs-Core/BlBError.class.st @@ -0,0 +1,29 @@ +Class { + #name : #BlBError, + #superclass : #Error, + #instVars : [ + 'exception' + ], + #category : #'BlocBenchs-Core-Errors' +} + +{ #category : #signalling } +BlBError class >> signalFor: anException [ + + self new + exception: anException; + messageText: anException messageText; + signal +] + +{ #category : #accessing } +BlBError >> exception [ + + ^ exception +] + +{ #category : #accessing } +BlBError >> exception: anObject [ + + exception := anObject +] diff --git a/src/BlocBenchs-Core/BlBFFICounterMeter.class.st b/src/BlocBenchs-Core/BlBFFICounterMeter.class.st index edea30a..e00966d 100644 --- a/src/BlocBenchs-Core/BlBFFICounterMeter.class.st +++ b/src/BlocBenchs-Core/BlBFFICounterMeter.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'functionNamesAndCounts' ], - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } { #category : #'as yet unclassified' } @@ -31,18 +31,16 @@ BlBFFICounterMeter >> startMetering: aBlBBlocBenchRunner [ "Really start" TFLFunctionCounter start. - - aBlBBlocBenchRunner space enableStatistics. ] { #category : #'as yet unclassified' } -BlBFFICounterMeter >> stopMetering: aBlBBlocBenchRunner [ +BlBFFICounterMeter >> stopMetering: aBlBBenchRunner [ "Extract relevant information of the global logger, and reset it." | frameCount | - frameCount := aBlBBlocBenchRunner space spaceStatistics totalFrames. + frameCount := aBlBBenchRunner totalFrames. functionNamesAndCounts := TFLFunctionCounter instance functionNamesAndCounts. functionNamesAndCounts := OrderedDictionary newFrom: diff --git a/src/BlocBenchs-Core/BlBFFILogger.class.st b/src/BlocBenchs-Core/BlBFFILogger.class.st index fc78172..a983cfd 100644 --- a/src/BlocBenchs-Core/BlBFFILogger.class.st +++ b/src/BlocBenchs-Core/BlBFFILogger.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'loggerCopy' ], - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } { #category : #'as yet unclassified' } diff --git a/src/BlocBenchs-Core/BlBMeter.class.st b/src/BlocBenchs-Core/BlBMeter.class.st index 8b91246..b8a8896 100644 --- a/src/BlocBenchs-Core/BlBMeter.class.st +++ b/src/BlocBenchs-Core/BlBMeter.class.st @@ -1,5 +1,10 @@ Class { #name : #BlBMeter, #superclass : #Object, - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } + +{ #category : #'as yet unclassified' } +BlBMeter >> startMetering: aBlBBlocBenchRunner [ + ^ self subclassResponsibility +] diff --git a/src/BlocBenchs-Core/BlBRawBenchRunner.class.st b/src/BlocBenchs-Core/BlBRawBenchRunner.class.st new file mode 100644 index 0000000..ebb8ce6 --- /dev/null +++ b/src/BlocBenchs-Core/BlBRawBenchRunner.class.st @@ -0,0 +1,131 @@ +Class { + #name : #BlBRawBenchRunner, + #superclass : #BlBAbstractBenchRunner, + #instVars : [ + 'sdlRenderer', + 'sdlWindow', + 'steppingProcess', + 'session', + 'delay', + 'stepError', + 'totalFrames', + 'currentFrames', + 'previousMillisecond', + 'fpsSamples' + ], + #pools : [ + 'SDL2Constants' + ], + #category : #'BlocBenchs-Core-Core' +} + +{ #category : #running } +BlBRawBenchRunner >> cleanUpAfterCase: aBlBRawCase [ + + steppingProcess ifNotNil: [ + steppingProcess terminate. + steppingProcess := nil ]. + + aBlBRawCase cleanUp. + + sdlRenderer ifNotNil: [ + sdlRenderer destroy. + sdlRenderer := nil ]. + + sdlWindow ifNotNil: [ + sdlWindow destroy. + sdlWindow := nil ] +] + +{ #category : #running } +BlBRawBenchRunner >> countFrames [ + + + | currentMillisecond fps | + totalFrames := totalFrames + 1. + currentFrames := currentFrames + 1. + + currentMillisecond := Time millisecondClockValue. + + (currentMillisecond >= (previousMillisecond + 1000)) + ifTrue: [ + fps := (currentFrames/ (currentMillisecond - previousMillisecond / 1000)) asFloat. + fpsSamples add: { currentMillisecond. fps }. + previousMillisecond := currentMillisecond. + currentFrames := 0] + +] + +{ #category : #running } +BlBRawBenchRunner >> defaultMeters [ + + ^ super defaultMeters , { BlBRawRenderingMeter new } +] + +{ #category : #running } +BlBRawBenchRunner >> doRun: aBlBRawCase [ + + self startSteppingProcess: aBlBRawCase. + delay := aBlBRawCase duration asDelay. + delay wait. + + stepError ifNotNil: [ BlBError signalFor: stepError ] + +] + +{ #category : #running } +BlBRawBenchRunner >> doStep: aBlBRawCase [ + + [ aBlBRawCase stepRender. + self countFrames ] onErrorDo: [ + :e | + stepError := e freeze. + delay delaySemaphore signal. + steppingProcess terminate ] +] + +{ #category : #accessing } +BlBRawBenchRunner >> fpsSamples [ + + ^ fpsSamples +] + +{ #category : #running } +BlBRawBenchRunner >> prepareBeforeRun: aBlBRawCase [ + + sdlWindow := SDL2 + createWindow: aBlBRawCase label + x: aBlBRawCase position x + y: aBlBRawCase position y + width: aBlBRawCase extent x + height: aBlBRawCase extent y + flags: SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI. "| SDL_WINDOW_OPENGL" + + sdlRenderer := sdlWindow createDefaultRenderer. + + aBlBRawCase beforeRunRenderer: sdlRenderer window: sdlWindow. + + totalFrames := 0. + fpsSamples := OrderedCollection new. + previousMillisecond := Time millisecondClockValue. + currentFrames := 0 +] + +{ #category : #running } +BlBRawBenchRunner >> startSteppingProcess: aBlBRawCase [ + + steppingProcess := [ + session := Smalltalk session. + [ session == Smalltalk session ] + whileTrue: [ self doStep: aBlBRawCase ] ] newProcess. + + steppingProcess + name: 'Step Loop ', self asString; + priority: Processor userSchedulingPriority; + resume +] + +{ #category : #accessing } +BlBRawBenchRunner >> totalFrames [ + ^ totalFrames +] diff --git a/src/BlocBenchs-Core/BlBRawCase.class.st b/src/BlocBenchs-Core/BlBRawCase.class.st new file mode 100644 index 0000000..6016137 --- /dev/null +++ b/src/BlocBenchs-Core/BlBRawCase.class.st @@ -0,0 +1,145 @@ +Class { + #name : #BlBRawCase, + #superclass : #BlBCase, + #instVars : [ + 'sdlRenderer', + 'mainTextureStrategy', + 'mainTextureStrategyClass', + 'cairoContext', + 'startMS', + 'deltaMS', + 'lastMS', + 'deviceScalePoint', + 'isHighDPI', + 'setupBlock' + ], + #category : #'BlocBenchs-Core-Core' +} + +{ #category : #running } +BlBRawCase >> beforeRunRenderer: aSDLRenderer window: aSDLWindow [ + + startMS := Time millisecondClockValue. + deltaMS := 0.0. + lastMS := startMS. + + sdlRenderer := aSDLRenderer. + + deviceScalePoint := sdlRenderer outputExtent / aSDLWindow extent. + isHighDPI := deviceScalePoint x > 1.0 or: [ deviceScalePoint y > 1.0 ]. + + setupBlock := [ :aCairoContext | + "Reduce quality options if it's a HiDPI display" + isHighDPI ifTrue: [ + aCairoContext + tolerance: 0.5; + antialias: AeCairoAntialias none. + aCairoContext surface deviceScale: deviceScalePoint ] ]. + + self setupMainTexture +] + +{ #category : #running } +BlBRawCase >> cleanUp [ + + sdlRenderer := nil. + mainTextureStrategy := nil +] + +{ #category : #drawing } +BlBRawCase >> clearCairoSurface [ + + cairoContext + sourceColor: Color white; + paint + +] + +{ #category : #accessing } +BlBRawCase >> defaultRunnerClass [ + + ^ BlBRawBenchRunner +] + +{ #category : #'drawing - steps' } +BlBRawCase >> drawDone [ + + mainTextureStrategy drawDone +] + +{ #category : #'drawing - steps' } +BlBRawCase >> drawOnCairoSurface [ + + self subclassResponsibility +] + +{ #category : #'drawing - steps' } +BlBRawCase >> drawPrepare [ + + mainTextureStrategy drawPrepare. + cairoContext := mainTextureStrategy cairoContext. +] + +{ #category : #accessing } +BlBRawCase >> elapsedMillisecondsSinceFirstDraw [ + + ^ lastMS - startMS +] + +{ #category : #accessing } +BlBRawCase >> extent [ + + ^ 800@600 +] + +{ #category : #initialization } +BlBRawCase >> initialize [ + + super initialize. + mainTextureStrategyClass := PCUpdateStaticTextureStrategy +] + +{ #category : #accessing } +BlBRawCase >> position [ + + ^ 30 asPoint +] + +{ #category : #'drawing - steps' } +BlBRawCase >> presentOnWindow [ + + sdlRenderer + copy: mainTextureStrategy sdlTexture; + present +] + +{ #category : #'drawing - steps' } +BlBRawCase >> setupMainTexture [ + + mainTextureStrategy := mainTextureStrategyClass + newExtent: sdlRenderer outputExtent + renderer: sdlRenderer + setupBlock: setupBlock. +] + +{ #category : #'drawing - steps' } +BlBRawCase >> stepAnimation [ + + | currentMS | + currentMS := Time millisecondClockValue. + deltaMS := currentMS - lastMS. + lastMS := currentMS. + +] + +{ #category : #'drawing - steps' } +BlBRawCase >> stepRender [ + + self stepAnimation. + self drawPrepare. + self drawOnCairoSurface. + self drawDone. + + self presentOnWindow + +] diff --git a/src/BlocBenchs-Core/BlBRawRenderingMeter.class.st b/src/BlocBenchs-Core/BlBRawRenderingMeter.class.st new file mode 100644 index 0000000..a191e4d --- /dev/null +++ b/src/BlocBenchs-Core/BlBRawRenderingMeter.class.st @@ -0,0 +1,50 @@ +Class { + #name : #BlBRawRenderingMeter, + #superclass : #BlBMeter, + #instVars : [ + 'initialTime', + 'finalTime' + ], + #category : #'BlocBenchs-Core-Core' +} + +{ #category : #'as yet unclassified' } +BlBRawRenderingMeter >> reportResultsFrom: aBlBRawBenchRunner in: aBlBResult [ + + | fpsSamples | + + fpsSamples := aBlBRawBenchRunner fpsSamples allButFirst collect: [:e | e second]. + + aBlBResult + addField: #totalRenderTime + title: 'Total Render Time (ms)' + value: finalTime - initialTime. + + aBlBResult + addField: #frameCount + title: 'Frame Count' + value: aBlBRawBenchRunner totalFrames. + + aBlBResult + addField: #fps + title: 'FPS mean and error margin (90% confidence level)' + value: (MeanConfidenceIntervalPrinter new print: fpsSamples). + + aBlBResult + addField: #fpsSamples + title: 'Raw FPS samples' + value: aBlBRawBenchRunner fpsSamples. + +] + +{ #category : #'as yet unclassified' } +BlBRawRenderingMeter >> startMetering: aBlBBlocBenchRunner [ + + initialTime := Time millisecondClockValue +] + +{ #category : #'as yet unclassified' } +BlBRawRenderingMeter >> stopMetering: aBlBBlocBenchRunner [ + + finalTime := Time millisecondClockValue +] diff --git a/src/BlocBenchs-Core/BlBResult.class.st b/src/BlocBenchs-Core/BlBResult.class.st index cac0752..998f153 100644 --- a/src/BlocBenchs-Core/BlBResult.class.st +++ b/src/BlocBenchs-Core/BlBResult.class.st @@ -6,7 +6,7 @@ Class { 'caseClassName', 'caseLabel' ], - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } { #category : #adding } diff --git a/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st b/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st index d110ce5..ece0e8d 100644 --- a/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st +++ b/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'profiler' ], - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } { #category : #'as yet unclassified' } diff --git a/src/BlocBenchs-Core/BlBTimeMeter.class.st b/src/BlocBenchs-Core/BlBTimeMeter.class.st index 2d8381f..f904008 100644 --- a/src/BlocBenchs-Core/BlBTimeMeter.class.st +++ b/src/BlocBenchs-Core/BlBTimeMeter.class.st @@ -5,7 +5,7 @@ Class { 'initialTime', 'finalTime' ], - #category : #'BlocBenchs-Core' + #category : #'BlocBenchs-Core-Core' } { #category : #'as yet unclassified' } diff --git a/src/BlocBenchs-FPS/BlBCompositionCase.class.st b/src/BlocBenchs-FPS/BlBCompositionCase.class.st new file mode 100644 index 0000000..a9d4ed2 --- /dev/null +++ b/src/BlocBenchs-FPS/BlBCompositionCase.class.st @@ -0,0 +1,70 @@ +Class { + #name : #BlBCompositionCase, + #superclass : #BlBBlocCase, + #traits : 'TBlBCompositionLogic', + #classTraits : 'TBlBCompositionLogic classTrait', + #instVars : [ + 'useSingleComposition' + ], + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #benchmarking } +BlBCompositionCase class >> benchMatrix [ + + ^ ParametrizedTestMatrix new + addCase: { #label -> 'BlBCompositionCase without using composition'. #useSingleComposition -> false}; + addCase: { #label -> 'BlBCompositionCase without using composition'. #useSingleComposition -> true}; + yourself +] + +{ #category : #hook } +BlBCompositionCase >> newElement [ + + | random backgroundColorGenerator container staticComplexElement | + random := self newRandom. + backgroundColorGenerator := self newColorGenerator. + + container := + BlElement new + size: self logicalExtent; + addAnimation: (BlBasicAnimation new + onStepDo: [ :target | target background: backgroundColorGenerator next ]; + yourself); + yourself. + + "static" + staticComplexElement := BlElement new + background: Color transparent; + size: self layerExtent; + yourself. + 1 to: self numberOfFigures do: [ :index | + staticComplexElement addChild: (self newFigure: random) ]. + container addChild: staticComplexElement. + + useSingleComposition + ifTrue: [ staticComplexElement beInSingleCompositionLayer ]. + + ^ container +] + +{ #category : #hook } +BlBCompositionCase >> newFigure: random [ + + ^ BlElement new + background: (Color random: random); + position: (self nextLocation: random); + size: self figureExtent; + yourself +] + +{ #category : #accessing } +BlBCompositionCase >> spaceExtent [ + + ^ self logicalExtent +] + +{ #category : #accessing } +BlBCompositionCase >> useSingleComposition: aBoolean [ + useSingleComposition := aBoolean +] diff --git a/src/BlocBenchs-FPS/PCBenchmarker.class.st b/src/BlocBenchs-FPS/PCBenchmarker.class.st index d688b53..ff1ae7a 100644 --- a/src/BlocBenchs-FPS/PCBenchmarker.class.st +++ b/src/BlocBenchs-FPS/PCBenchmarker.class.st @@ -47,9 +47,9 @@ PCBenchmarker class >> exampleAllBenchsWithRaw [ PCBenchmarker class >> exampleAllSDL2Drivers [ | case driverNames | - case := PCBoxWindmillBenchCase new. - "case := PCCompositionEnabledBenchCase new." - case numberOfSeconds: 30. + "case := PCBoxWindmillBenchCase new." +" case := PCCompositionEnabledBenchCase new. +" case numberOfSeconds: 30. driverNames := SDL2 renderDriverInfos collect: #nameString. @@ -95,43 +95,6 @@ PCBenchmarker class >> exampleAnimations [ ] -{ #category : #examples } -PCBenchmarker class >> exampleBunchOfBenchs [ - - PCBenchmarkSuite new - - addCase: PCSolidCirclesBenchCase new; - addCase: PCDashedBorderCirclesBenchCase new; - addCase: (PCOutskirtsBenchCase new - beTranslucentBackgroundColor; - outskirts: BlOutskirts outside; - yourself); - addCase: PCHexagonBenchCase new; - addCase: PCLinearGradientCirclesBenchCase new; - addCase: PCRadialGradientCirclesBenchCase new; - addCase: PCBoxWindmillBenchCase new; - addCase: PCTextBenchCase new; - addCase: PCRoundedRectanglesBenchCase new; - - numberOfSeconds: 4; -" addSpartaCairoBenchmarker;" - addAlexandrieBenchmarker; - runInForkWithGUI - -] - -{ #category : #examples } -PCBenchmarker class >> exampleComposition [ - - PCBenchmarkSuite new - addCase: PCCompositionEnabledBenchCase new; - addCase: PCCompositionDisabledBenchCase new; - numberOfSeconds: 10; - addAlexandrieBenchmarker; - runInForkWithGUI - -] - { #category : #examples } PCBenchmarker class >> exampleFFI [ diff --git a/src/BlocBenchs-FPS/PCBoxWindmillBenchCase.class.st b/src/BlocBenchs-FPS/PCBoxWindmillBenchCase.class.st deleted file mode 100644 index 97dee44..0000000 --- a/src/BlocBenchs-FPS/PCBoxWindmillBenchCase.class.st +++ /dev/null @@ -1,114 +0,0 @@ -" -Inspired on RSAnimationExamples>>#example01BoxWindmill - - -" -Class { - #name : #PCBoxWindmillBenchCase, - #superclass : #PCBenchCase, - #category : #'BlocBenchs-FPS-Cases' -} - -{ #category : #hook } -PCBoxWindmillBenchCase >> backgroundColor [ - - ^ Color black -] - -{ #category : #hook } -PCBoxWindmillBenchCase >> boxBorderColor [ - - ^ Color blue muchDarker alpha: 0.5 -] - -{ #category : #hook } -PCBoxWindmillBenchCase >> boxBorderWidth [ - - ^ 10 -] - -{ #category : #hook } -PCBoxWindmillBenchCase >> boxColor [ - - ^ Color white -] - -{ #category : #hook } -PCBoxWindmillBenchCase >> boxExtent [ - - ^ 140 @ 40 -] - -{ #category : #hook } -PCBoxWindmillBenchCase >> boxPositions [ - "Answer the logical positions for the boxes" - - ^ self boxPositions: 1@1 -] - -{ #category : #hook } -PCBoxWindmillBenchCase >> boxPositions: aDeviceScale [ - "Answer the positions for the boxes in the pixel space" - - ^ (0 to: self logicalExtent x * aDeviceScale x by: 50 * aDeviceScale x) flatCollect: [ :x | - (0 to: self logicalExtent y * aDeviceScale y by: 50 * aDeviceScale y) collect: [ :y | - (x @ y) - (self boxExtent * aDeviceScale / 2) ] ] -] - -{ #category : #hook } -PCBoxWindmillBenchCase >> boxRotationInDegreesWithPosition: position elapsedMS: elapsedMS [ - - ^ ((position x + position y + (elapsedMS/50.0) ) degreesToRadians * 1.95) radiansToDegrees -] - -{ #category : #accessing } -PCBoxWindmillBenchCase >> logicalExtent [ - - ^ 800 asPoint -] - -{ #category : #hook } -PCBoxWindmillBenchCase >> 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 -] - -{ #category : #'instance creation' } -PCBoxWindmillBenchCase >> newRawSDLCairoWindow [ - - ^ PCBoxWindmillCompositingWindow newWith: self -] diff --git a/src/BlocBenchs-FPS/PCBoxWindmillWindow.class.st b/src/BlocBenchs-FPS/PCBoxWindmillWindow.class.st deleted file mode 100644 index 51d2238..0000000 --- a/src/BlocBenchs-FPS/PCBoxWindmillWindow.class.st +++ /dev/null @@ -1,36 +0,0 @@ -" -See RSAnimationExamples>>#example01BoxWindmill -" -Class { - #name : #PCBoxWindmillWindow, - #superclass : #PCCleanCanvasWindow, - #instVars : [ - 'figurePositions', - 'figureColors', - 'backgroundColorGenerator' - ], - #category : #'BlocBenchs-FPS-Raw' -} - -{ #category : #drawing } -PCBoxWindmillWindow >> drawBoxOn: aeCairoContext [ - - "set path (outskirts = center)" - aeCairoContext - rectangleX: case boxBorderWidth / 2 - y: case boxBorderWidth / 2 - width: case boxExtent x - height: case boxExtent y. - - "draw background" - aeCairoContext - sourceColor: case boxColor; - fillPreserve. - - "draw border" - aeCairoContext - sourceColor: case boxBorderColor; - lineWidth: case boxBorderWidth; - stroke. - -] diff --git a/src/BlocBenchs-FPS/PCCompositionDisabledBenchCase.class.st b/src/BlocBenchs-FPS/PCCompositionDisabledBenchCase.class.st deleted file mode 100644 index 88f8a9e..0000000 --- a/src/BlocBenchs-FPS/PCCompositionDisabledBenchCase.class.st +++ /dev/null @@ -1,16 +0,0 @@ -Class { - #name : #PCCompositionDisabledBenchCase, - #superclass : #PCCompositionBenchCase, - #category : #'BlocBenchs-FPS-Cases' -} - -{ #category : #'instance creation' } -PCCompositionDisabledBenchCase >> newRawSDLCairoWindow [ - - ^ PCCompositionDisabledWindow newWith: self -] - -{ #category : #hook } -PCCompositionDisabledBenchCase >> prepareAsStatic: anElement [ - -] diff --git a/src/BlocBenchs-FPS/PCCompositionEnabledBenchCase.class.st b/src/BlocBenchs-FPS/PCCompositionEnabledBenchCase.class.st deleted file mode 100644 index c64a131..0000000 --- a/src/BlocBenchs-FPS/PCCompositionEnabledBenchCase.class.st +++ /dev/null @@ -1,17 +0,0 @@ -Class { - #name : #PCCompositionEnabledBenchCase, - #superclass : #PCCompositionBenchCase, - #category : #'BlocBenchs-FPS-Cases' -} - -{ #category : #'instance creation' } -PCCompositionEnabledBenchCase >> newRawSDLCairoWindow [ - - ^ PCCompositionEnabledViaSDLWindow newWith: self -] - -{ #category : #hook } -PCCompositionEnabledBenchCase >> prepareAsStatic: anElement [ - - anElement beInSingleCompositionLayer -] From 09ae5c996d1cd1d302b37c3cf11759be1268bc0a Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Tue, 26 Nov 2024 20:04:12 +0100 Subject: [PATCH 06/23] Fixing duplicated class --- .../BlBCompositionCase.class.st | 70 ------------------- 1 file changed, 70 deletions(-) delete mode 100644 src/BlocBenchs-FPS/BlBCompositionCase.class.st diff --git a/src/BlocBenchs-FPS/BlBCompositionCase.class.st b/src/BlocBenchs-FPS/BlBCompositionCase.class.st deleted file mode 100644 index a9d4ed2..0000000 --- a/src/BlocBenchs-FPS/BlBCompositionCase.class.st +++ /dev/null @@ -1,70 +0,0 @@ -Class { - #name : #BlBCompositionCase, - #superclass : #BlBBlocCase, - #traits : 'TBlBCompositionLogic', - #classTraits : 'TBlBCompositionLogic classTrait', - #instVars : [ - 'useSingleComposition' - ], - #category : #'BlocBenchs-Benchs-Bloc' -} - -{ #category : #benchmarking } -BlBCompositionCase class >> benchMatrix [ - - ^ ParametrizedTestMatrix new - addCase: { #label -> 'BlBCompositionCase without using composition'. #useSingleComposition -> false}; - addCase: { #label -> 'BlBCompositionCase without using composition'. #useSingleComposition -> true}; - yourself -] - -{ #category : #hook } -BlBCompositionCase >> newElement [ - - | random backgroundColorGenerator container staticComplexElement | - random := self newRandom. - backgroundColorGenerator := self newColorGenerator. - - container := - BlElement new - size: self logicalExtent; - addAnimation: (BlBasicAnimation new - onStepDo: [ :target | target background: backgroundColorGenerator next ]; - yourself); - yourself. - - "static" - staticComplexElement := BlElement new - background: Color transparent; - size: self layerExtent; - yourself. - 1 to: self numberOfFigures do: [ :index | - staticComplexElement addChild: (self newFigure: random) ]. - container addChild: staticComplexElement. - - useSingleComposition - ifTrue: [ staticComplexElement beInSingleCompositionLayer ]. - - ^ container -] - -{ #category : #hook } -BlBCompositionCase >> newFigure: random [ - - ^ BlElement new - background: (Color random: random); - position: (self nextLocation: random); - size: self figureExtent; - yourself -] - -{ #category : #accessing } -BlBCompositionCase >> spaceExtent [ - - ^ self logicalExtent -] - -{ #category : #accessing } -BlBCompositionCase >> useSingleComposition: aBoolean [ - useSingleComposition := aBoolean -] From 9a0529d65981327cb5e1bcd8ca600f0353810e57 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Tue, 3 Dec 2024 14:55:49 +0100 Subject: [PATCH 07/23] Migrating Benchs --- .../BlBAbstractCircleCase.class.st | 46 ++++++ .../BlBAbstractGradientCirclesCase.class.st | 68 +++++++++ .../BlBAbstractImagesCase.class.st | 35 +++++ ...BlBAbstractTranslatingFiguresCase.class.st | 133 ++++++++++++++++++ .../BlBAnnulusSectorCase.class.st} | 10 +- .../BlBClippedImagesCase.class.st} | 8 +- .../BlBDashedBorderCirclesCase.class.st} | 10 +- .../BlBLinearGradientCirclesCase.class.st | 15 ++ .../BlBNestedTransformationsCase.class.st} | 52 +------ .../BlBNestedTransformationsRawCase.class.st} | 52 ++++--- .../BlBOutskirtsBenchCase.class.st} | 96 +++++-------- .../BlBRadialGradientCirclesCase.class.st | 15 ++ .../BlBRotatedImagesCase.class.st} | 8 +- .../BlBRotatedRectanglesCase.class.st} | 10 +- .../BlBRotatedTextCase.class.st} | 16 +-- .../BlBScaledRectanglesCase.class.st} | 12 +- .../BlBSolidImagesCase.class.st | 17 +++ .../BlBSolidImagesRawCase.class.st | 76 ++++++++++ .../BlBTextCase.class.st} | 18 +-- .../BlBTranslucentEllipsesCase.class.st} | 10 +- .../BlBTranslucentImagesCase.class.st} | 8 +- .../BlRoundedRectanglesCase.class.st} | 10 +- .../TBlBAbstractImagesLogic.trait.st | 40 ++++++ .../TBlBNestedTransformationsLogic.trait.st | 40 ++++++ src/BlocBenchs-Core/BlBBlocCase.class.st | 6 + src/BlocBenchs-Core/BlBCase.class.st | 8 +- src/BlocBenchs-Core/BlBRawCase.class.st | 16 +++ .../PCCirclesBenchCase.class.st | 35 ----- .../PCGradientCirclesBenchCase.class.st | 62 -------- src/BlocBenchs-FPS/PCImagesBenchCase.class.st | 63 --------- .../PCLinearGradientCirclesBenchCase.class.st | 20 --- .../PCRadialGradientCirclesBenchCase.class.st | 20 --- .../PCSolidImagesBenchCase.class.st | 23 --- .../PCSolidImagesWindow.class.st | 55 -------- .../PCTranslatingFiguresBenchCase.class.st | 113 --------------- 35 files changed, 646 insertions(+), 580 deletions(-) create mode 100644 src/BlocBenchs-Benchs/BlBAbstractCircleCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBAbstractGradientCirclesCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBAbstractImagesCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBAbstractTranslatingFiguresCase.class.st rename src/{BlocBenchs-FPS/PCAnnulusSectorBenchCase.class.st => BlocBenchs-Benchs/BlBAnnulusSectorCase.class.st} (64%) rename src/{BlocBenchs-FPS/PCClippedImagesBenchCase.class.st => BlocBenchs-Benchs/BlBClippedImagesCase.class.st} (60%) rename src/{BlocBenchs-FPS/PCDashedBorderCirclesBenchCase.class.st => BlocBenchs-Benchs/BlBDashedBorderCirclesCase.class.st} (56%) create mode 100644 src/BlocBenchs-Benchs/BlBLinearGradientCirclesCase.class.st rename src/{BlocBenchs-FPS/PCNestedTransformationsBenchCase.class.st => BlocBenchs-Benchs/BlBNestedTransformationsCase.class.st} (55%) rename src/{BlocBenchs-FPS/PCNestedTransformationsWindow.class.st => BlocBenchs-Benchs/BlBNestedTransformationsRawCase.class.st} (53%) rename src/{BlocBenchs-FPS/PCOutskirtsBenchCase.class.st => BlocBenchs-Benchs/BlBOutskirtsBenchCase.class.st} (52%) create mode 100644 src/BlocBenchs-Benchs/BlBRadialGradientCirclesCase.class.st rename src/{BlocBenchs-FPS/PCRotatedImagesBenchCase.class.st => BlocBenchs-Benchs/BlBRotatedImagesCase.class.st} (61%) rename src/{BlocBenchs-FPS/PCRotatedRectanglesBenchCase.class.st => BlocBenchs-Benchs/BlBRotatedRectanglesCase.class.st} (56%) rename src/{BlocBenchs-FPS/PCRotatedTextBenchCase.class.st => BlocBenchs-Benchs/BlBRotatedTextCase.class.st} (57%) rename src/{BlocBenchs-FPS/PCScaledRectanglesBenchCase.class.st => BlocBenchs-Benchs/BlBScaledRectanglesCase.class.st} (55%) create mode 100644 src/BlocBenchs-Benchs/BlBSolidImagesCase.class.st create mode 100644 src/BlocBenchs-Benchs/BlBSolidImagesRawCase.class.st rename src/{BlocBenchs-FPS/PCTextBenchCase.class.st => BlocBenchs-Benchs/BlBTextCase.class.st} (56%) rename src/{BlocBenchs-FPS/PCTranslucentEllipsesBenchCase.class.st => BlocBenchs-Benchs/BlBTranslucentEllipsesCase.class.st} (58%) rename src/{BlocBenchs-FPS/PCTranslucentImagesBenchCase.class.st => BlocBenchs-Benchs/BlBTranslucentImagesCase.class.st} (57%) rename src/{BlocBenchs-FPS/PCRoundedRectanglesBenchCase.class.st => BlocBenchs-Benchs/BlRoundedRectanglesCase.class.st} (51%) create mode 100644 src/BlocBenchs-Benchs/TBlBAbstractImagesLogic.trait.st create mode 100644 src/BlocBenchs-Benchs/TBlBNestedTransformationsLogic.trait.st delete mode 100644 src/BlocBenchs-FPS/PCGradientCirclesBenchCase.class.st delete mode 100644 src/BlocBenchs-FPS/PCImagesBenchCase.class.st delete mode 100644 src/BlocBenchs-FPS/PCLinearGradientCirclesBenchCase.class.st delete mode 100644 src/BlocBenchs-FPS/PCRadialGradientCirclesBenchCase.class.st delete mode 100644 src/BlocBenchs-FPS/PCSolidImagesBenchCase.class.st delete mode 100644 src/BlocBenchs-FPS/PCSolidImagesWindow.class.st diff --git a/src/BlocBenchs-Benchs/BlBAbstractCircleCase.class.st b/src/BlocBenchs-Benchs/BlBAbstractCircleCase.class.st new file mode 100644 index 0000000..84a0fc2 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBAbstractCircleCase.class.st @@ -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 +] diff --git a/src/BlocBenchs-Benchs/BlBAbstractGradientCirclesCase.class.st b/src/BlocBenchs-Benchs/BlBAbstractGradientCirclesCase.class.st new file mode 100644 index 0000000..39c1b9e --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBAbstractGradientCirclesCase.class.st @@ -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) +] diff --git a/src/BlocBenchs-Benchs/BlBAbstractImagesCase.class.st b/src/BlocBenchs-Benchs/BlBAbstractImagesCase.class.st new file mode 100644 index 0000000..8049d33 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBAbstractImagesCase.class.st @@ -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 +] diff --git a/src/BlocBenchs-Benchs/BlBAbstractTranslatingFiguresCase.class.st b/src/BlocBenchs-Benchs/BlBAbstractTranslatingFiguresCase.class.st new file mode 100644 index 0000000..99876de --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBAbstractTranslatingFiguresCase.class.st @@ -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 +] diff --git a/src/BlocBenchs-FPS/PCAnnulusSectorBenchCase.class.st b/src/BlocBenchs-Benchs/BlBAnnulusSectorCase.class.st similarity index 64% rename from src/BlocBenchs-FPS/PCAnnulusSectorBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBAnnulusSectorCase.class.st index adc3810..0ffc04b 100644 --- a/src/BlocBenchs-FPS/PCAnnulusSectorBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBAnnulusSectorCase.class.st @@ -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); diff --git a/src/BlocBenchs-FPS/PCClippedImagesBenchCase.class.st b/src/BlocBenchs-Benchs/BlBClippedImagesCase.class.st similarity index 60% rename from src/BlocBenchs-FPS/PCClippedImagesBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBClippedImagesCase.class.st index a249c65..5a4d3ff 100644 --- a/src/BlocBenchs-FPS/PCClippedImagesBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBClippedImagesCase.class.st @@ -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. diff --git a/src/BlocBenchs-FPS/PCDashedBorderCirclesBenchCase.class.st b/src/BlocBenchs-Benchs/BlBDashedBorderCirclesCase.class.st similarity index 56% rename from src/BlocBenchs-FPS/PCDashedBorderCirclesBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBDashedBorderCirclesCase.class.st index 53d82f3..e875df8 100644 --- a/src/BlocBenchs-FPS/PCDashedBorderCirclesBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBDashedBorderCirclesCase.class.st @@ -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 diff --git a/src/BlocBenchs-Benchs/BlBLinearGradientCirclesCase.class.st b/src/BlocBenchs-Benchs/BlBLinearGradientCirclesCase.class.st new file mode 100644 index 0000000..d43df18 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBLinearGradientCirclesCase.class.st @@ -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. +] diff --git a/src/BlocBenchs-FPS/PCNestedTransformationsBenchCase.class.st b/src/BlocBenchs-Benchs/BlBNestedTransformationsCase.class.st similarity index 55% rename from src/BlocBenchs-FPS/PCNestedTransformationsBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBNestedTransformationsCase.class.st index 28b3882..4bafeea 100644 --- a/src/BlocBenchs-FPS/PCNestedTransformationsBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBNestedTransformationsCase.class.st @@ -1,29 +1,13 @@ Class { - #name : #PCNestedTransformationsBenchCase, - #superclass : #PCBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlBNestedTransformationsCase, + #superclass : #BlBBlocCase, + #traits : 'TBlBNestedTransformationsLogic', + #classTraits : 'TBlBNestedTransformationsLogic classTrait', + #category : #'BlocBenchs-Benchs-Bloc' } -{ #category : #accessing } -PCNestedTransformationsBenchCase >> figureExtent [ - - ^ 600.0 asPoint -] - -{ #category : #hook } -PCNestedTransformationsBenchCase >> figureOffset [ - - ^ 50.0 asPoint -] - -{ #category : #accessing } -PCNestedTransformationsBenchCase >> logicalExtent [ - - ^ 750 @ 750 -] - { #category : #hook } -PCNestedTransformationsBenchCase >> newElement [ +BlBNestedTransformationsCase >> newElement [ | elements random anAnimation | random := self newRandom. @@ -68,27 +52,3 @@ PCNestedTransformationsBenchCase >> newElement [ position: self figureOffset; yourself ] - -{ #category : #hook } -PCNestedTransformationsBenchCase >> newRawSDLCairoWindow [ - - ^ PCNestedTransformationsWindow newWith: self -] - -{ #category : #accessing } -PCNestedTransformationsBenchCase >> numberOfFigures [ - - ^ 50 -] - -{ #category : #accessing } -PCNestedTransformationsBenchCase >> targetRelativeRotation [ - - ^ 5.0 -] - -{ #category : #accessing } -PCNestedTransformationsBenchCase >> targetRelativeScale [ - - ^ 0.9 -] diff --git a/src/BlocBenchs-FPS/PCNestedTransformationsWindow.class.st b/src/BlocBenchs-Benchs/BlBNestedTransformationsRawCase.class.st similarity index 53% rename from src/BlocBenchs-FPS/PCNestedTransformationsWindow.class.st rename to src/BlocBenchs-Benchs/BlBNestedTransformationsRawCase.class.st index d785b31..d1e0f35 100644 --- a/src/BlocBenchs-FPS/PCNestedTransformationsWindow.class.st +++ b/src/BlocBenchs-Benchs/BlBNestedTransformationsRawCase.class.st @@ -1,25 +1,28 @@ Class { - #name : #PCNestedTransformationsWindow, - #superclass : #PCBenchCaseRawSDLCairoWindow, + #name : #BlBNestedTransformationsRawCase, + #superclass : #BlBRawCase, + #traits : 'TBlBNestedTransformationsLogic', + #classTraits : 'TBlBNestedTransformationsLogic classTrait', #instVars : [ - 'backgroundColors', - 'figureMatrices', - 'rotationPerMS', - 'scalePerMS', 'rotationCenter', + 'figureMatrices', 'rotationCenterNegated', - 'windowColor' + 'backgroundColors', + 'windowColor', + 'random', + 'scalePerMS', + 'rotationPerMS' ], - #category : #'BlocBenchs-FPS-Raw' + #category : #'BlocBenchs-Benchs-Raw' } { #category : #drawing } -PCNestedTransformationsWindow >> drawOnCairoCanvasFigureAt: index [ +BlBNestedTransformationsRawCase >> drawOnCairoCanvasFigureAt: index [ cairoContext setIdentityMatrix. "Translate to figure's position" - cairoContext translateBy: case figureOffset. + cairoContext translateBy: self figureOffset. "Apply figure's transformation using the right origin" cairoContext @@ -31,8 +34,8 @@ PCNestedTransformationsWindow >> drawOnCairoCanvasFigureAt: index [ cairoContext rectangleX: 0.0 y: 0.0 - width: case figureExtent x - height: case figureExtent y; + width: self figureExtent x + height: self figureExtent y; sourceColor: (backgroundColors at: index); fill. @@ -40,21 +43,21 @@ PCNestedTransformationsWindow >> drawOnCairoCanvasFigureAt: index [ ] { #category : #stepping } -PCNestedTransformationsWindow >> drawOnCairoSurface [ +BlBNestedTransformationsRawCase >> drawOnCairoSurface [ "Prepare on first draw" backgroundColors ifNil: [ windowColor := PCFloatColor newFrom: Color white. - backgroundColors := (1 to: case numberOfFigures) + backgroundColors := (1 to: self numberOfFigures) collect: [ :each | PCFloatColor newRandom: random ]. - figureMatrices := (1 to: case numberOfFigures) + figureMatrices := (1 to: self numberOfFigures) collect: [:each | AeCairoMatrix newIdentity ]. - scalePerMS := case targetRelativeScale / - (case numberOfMilliseconds * 10.0). "Why 10x more?" - rotationPerMS := case targetRelativeRotation degreesToRadians / - case numberOfMilliseconds. - rotationCenter := case figureExtent / 2.0. + scalePerMS := self targetRelativeScale / + (self numberOfMilliseconds * 10.0). "Why 10x more?" + rotationPerMS := self targetRelativeRotation degreesToRadians / + self numberOfMilliseconds. + rotationCenter := self figureExtent / 2.0. rotationCenterNegated := rotationCenter negated ] ifNotNil: [ figureMatrices withIndexDo: [ :each :index | @@ -69,7 +72,14 @@ PCNestedTransformationsWindow >> drawOnCairoSurface [ paint. "Draw each figure" - 1 to: case numberOfFigures do: [ :index | + 1 to: self numberOfFigures do: [ :index | self drawOnCairoCanvasFigureAt: index ] ] + +{ #category : #initialization } +BlBNestedTransformationsRawCase >> initialize [ + + super initialize. + random := self newRandom +] diff --git a/src/BlocBenchs-FPS/PCOutskirtsBenchCase.class.st b/src/BlocBenchs-Benchs/BlBOutskirtsBenchCase.class.st similarity index 52% rename from src/BlocBenchs-FPS/PCOutskirtsBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBOutskirtsBenchCase.class.st index 85373e4..52cee83 100644 --- a/src/BlocBenchs-FPS/PCOutskirtsBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBOutskirtsBenchCase.class.st @@ -1,106 +1,80 @@ -" -I'm a parameterized bench case to cover the variants of element geometries as rendered by Bloc-Alexanderie's canvas. -" Class { - #name : #PCOutskirtsBenchCase, - #superclass : #PCTranslatingFiguresBenchCase, + #name : #BlBOutskirtsBenchCase, + #superclass : #BlBAbstractTranslatingFiguresCase, #instVars : [ 'backgroundColor', 'outskirts', 'mustClipChildren', - 'backgroundLabel', 'useExplicitBorderPathGeometry' ], - #category : #'BlocBenchs-FPS-Cases' + #category : #'BlocBenchs-Benchs-Bloc' } -{ #category : #hook } -PCOutskirtsBenchCase >> backgroundColor [ - - ^ backgroundColor -] - -{ #category : #hook } -PCOutskirtsBenchCase >> backgroundColor: aColor [ - - backgroundColor := aColor -] - -{ #category : #hook } -PCOutskirtsBenchCase >> beNoBackgroundColor [ +{ #category : #benchmarking } +BlBOutskirtsBenchCase class >> benchMatrix [ - backgroundColor := Color transparent. - backgroundLabel := 'No' + ^ super benchMatrix + forSelector: #mustClipChildren addOptions: #(true false); + forSelector: #outskirts addOptions: { BlOutskirts centered. BlOutskirts inside. BlOutskirts outside }; + forSelector: #backgroundColor addOptions: { Color transparent. Color orange. Color green alpha: 0.1. }; + forSelector: #useExplicitBorderPathGeometry addOptions: #(true false) ] { #category : #hook } -PCOutskirtsBenchCase >> beOpaqueBackgroundColor [ +BlBOutskirtsBenchCase >> backgroundColor [ - backgroundColor := Color orange. - backgroundLabel := 'Opaque' + ^ backgroundColor ] { #category : #hook } -PCOutskirtsBenchCase >> beTranslucentBackgroundColor [ +BlBOutskirtsBenchCase >> backgroundColor: aColor [ - backgroundColor := Color green alpha: 0.1. - backgroundLabel := 'Translucent' + backgroundColor := aColor ] { #category : #hook } -PCOutskirtsBenchCase >> borderColorWith: random [ +BlBOutskirtsBenchCase >> borderColorWith: random [ ^ (Color random: random) alpha: 0.3 ] { #category : #hook } -PCOutskirtsBenchCase >> borderWidth [ +BlBOutskirtsBenchCase >> borderWidth [ ^ 12 ] -{ #category : #accessing } -PCOutskirtsBenchCase >> figureExtent [ - - ^ 100 asPoint -] - -{ #category : #initialization } -PCOutskirtsBenchCase >> initialize [ - - super initialize. - - self - mustClipChildren: true; - outskirts: BlOutskirts inside; - beTranslucentBackgroundColor; - useExplicitBorderPathGeometry: true. -] - { #category : #printing } -PCOutskirtsBenchCase >> label [ +BlBOutskirtsBenchCase >> defaultLabel [ - ^ '{1} border & clipping={3} & {2} background' format: { - outskirts class name splitCamelCase last. - backgroundLabel. + ^ '{1} outskirts: {2} border: {3} clipping: {4} & explicitBorder: {5}' format: { + super defaultLabel. + outskirts class name. + backgroundColor. mustClipChildren. useExplicitBorderPathGeometry } ] { #category : #accessing } -PCOutskirtsBenchCase >> mustClipChildren [ +BlBOutskirtsBenchCase >> figureExtent [ + + ^ 100 asPoint +] + +{ #category : #accessing } +BlBOutskirtsBenchCase >> mustClipChildren [ ^ mustClipChildren ] { #category : #accessing } -PCOutskirtsBenchCase >> mustClipChildren: aBoolean [ +BlBOutskirtsBenchCase >> mustClipChildren: aBoolean [ mustClipChildren := aBoolean ] { #category : #hook } -PCOutskirtsBenchCase >> newChildWith: random [ +BlBOutskirtsBenchCase >> newChildWith: random [ ^ BlElement new geometry: BlRectangleGeometry new; @@ -110,7 +84,7 @@ PCOutskirtsBenchCase >> newChildWith: random [ ] { #category : #hook } -PCOutskirtsBenchCase >> newFigureGeometry [ +BlBOutskirtsBenchCase >> newFigureGeometry [ | cornerRadius | cornerRadius := 25. @@ -130,7 +104,7 @@ PCOutskirtsBenchCase >> newFigureGeometry [ ] { #category : #hook } -PCOutskirtsBenchCase >> newFigureWith: random [ +BlBOutskirtsBenchCase >> newFigureWith: random [ ^ BlElement new border: (BlBorder paint: (self borderColorWith: random) width: self borderWidth); @@ -144,19 +118,19 @@ PCOutskirtsBenchCase >> newFigureWith: random [ ] { #category : #hook } -PCOutskirtsBenchCase >> outskirts [ +BlBOutskirtsBenchCase >> outskirts [ ^ outskirts ] { #category : #hook } -PCOutskirtsBenchCase >> outskirts: aBlOutskirts [ +BlBOutskirtsBenchCase >> outskirts: aBlOutskirts [ outskirts := aBlOutskirts ] { #category : #accessing } -PCOutskirtsBenchCase >> useExplicitBorderPathGeometry: aBoolean [ +BlBOutskirtsBenchCase >> useExplicitBorderPathGeometry: aBoolean [ useExplicitBorderPathGeometry := aBoolean ] diff --git a/src/BlocBenchs-Benchs/BlBRadialGradientCirclesCase.class.st b/src/BlocBenchs-Benchs/BlBRadialGradientCirclesCase.class.st new file mode 100644 index 0000000..3503924 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBRadialGradientCirclesCase.class.st @@ -0,0 +1,15 @@ +Class { + #name : #BlBRadialGradientCirclesCase, + #superclass : #BlBAbstractGradientCirclesCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #'instance creation' } +BlBRadialGradientCirclesCase >> newGradient: random [ + + ^ BlRadialGradientPaint new + center: self radius; + radius: self radius x; + stops: (self newStops: random); + yourself. +] diff --git a/src/BlocBenchs-FPS/PCRotatedImagesBenchCase.class.st b/src/BlocBenchs-Benchs/BlBRotatedImagesCase.class.st similarity index 61% rename from src/BlocBenchs-FPS/PCRotatedImagesBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBRotatedImagesCase.class.st index 7321998..d96d6b6 100644 --- a/src/BlocBenchs-FPS/PCRotatedImagesBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBRotatedImagesCase.class.st @@ -1,11 +1,11 @@ Class { - #name : #PCRotatedImagesBenchCase, - #superclass : #PCImagesBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlBRotatedImagesCase, + #superclass : #BlBAbstractImagesCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #'instance creation' } -PCRotatedImagesBenchCase >> newImageElementWith: random [ +BlBRotatedImagesCase >> newImageElementWith: random [ | randomIcon | randomIcon := self newFormWith: random. diff --git a/src/BlocBenchs-FPS/PCRotatedRectanglesBenchCase.class.st b/src/BlocBenchs-Benchs/BlBRotatedRectanglesCase.class.st similarity index 56% rename from src/BlocBenchs-FPS/PCRotatedRectanglesBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBRotatedRectanglesCase.class.st index 2f8b6a1..b00bbb1 100644 --- a/src/BlocBenchs-FPS/PCRotatedRectanglesBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBRotatedRectanglesCase.class.st @@ -1,17 +1,17 @@ Class { - #name : #PCRotatedRectanglesBenchCase, - #superclass : #PCTranslatingFiguresBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlBRotatedRectanglesCase, + #superclass : #BlBAbstractTranslatingFiguresCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #accessing } -PCRotatedRectanglesBenchCase >> figureExtent [ +BlBRotatedRectanglesCase >> figureExtent [ ^ 100.0 asPoint ] { #category : #hook } -PCRotatedRectanglesBenchCase >> newFigureWith: random [ +BlBRotatedRectanglesCase >> newFigureWith: random [ ^ BlElement new background: (Color random: random); diff --git a/src/BlocBenchs-FPS/PCRotatedTextBenchCase.class.st b/src/BlocBenchs-Benchs/BlBRotatedTextCase.class.st similarity index 57% rename from src/BlocBenchs-FPS/PCRotatedTextBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBRotatedTextCase.class.st index 08af3d8..dbfc91b 100644 --- a/src/BlocBenchs-FPS/PCRotatedTextBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBRotatedTextCase.class.st @@ -1,11 +1,11 @@ Class { - #name : #PCRotatedTextBenchCase, - #superclass : #PCTranslatingFiguresBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlBRotatedTextCase, + #superclass : #BlBAbstractTranslatingFiguresCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #hook } -PCRotatedTextBenchCase >> blTextFor: random [ +BlBRotatedTextCase >> blTextFor: random [ ^ (BlRopedText string: (String loremIpsum: 90)) fontSize: 8; @@ -15,13 +15,13 @@ PCRotatedTextBenchCase >> blTextFor: random [ ] { #category : #accessing } -PCRotatedTextBenchCase >> logicalExtent [ +BlBRotatedTextCase >> logicalExtent [ ^ 900 @ 500 ] { #category : #hook } -PCRotatedTextBenchCase >> newFigureWith: random [ +BlBRotatedTextCase >> newFigureWith: random [ ^ BlTextElement new text: (self blTextFor: random); @@ -32,13 +32,13 @@ PCRotatedTextBenchCase >> newFigureWith: random [ ] { #category : #accessing } -PCRotatedTextBenchCase >> numberOfFigures [ +BlBRotatedTextCase >> numberOfFigures [ ^ 100 ] { #category : #hook } -PCRotatedTextBenchCase >> offsetBetweenFigures [ +BlBRotatedTextCase >> offsetBetweenFigures [ ^ 7 @ 0 ] diff --git a/src/BlocBenchs-FPS/PCScaledRectanglesBenchCase.class.st b/src/BlocBenchs-Benchs/BlBScaledRectanglesCase.class.st similarity index 55% rename from src/BlocBenchs-FPS/PCScaledRectanglesBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBScaledRectanglesCase.class.st index 4227f31..93bd666 100644 --- a/src/BlocBenchs-FPS/PCScaledRectanglesBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBScaledRectanglesCase.class.st @@ -1,17 +1,17 @@ Class { - #name : #PCScaledRectanglesBenchCase, - #superclass : #PCTranslatingFiguresBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlBScaledRectanglesCase, + #superclass : #BlBAbstractTranslatingFiguresCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #accessing } -PCScaledRectanglesBenchCase >> figureExtent [ +BlBScaledRectanglesCase >> figureExtent [ ^ 100.0 asPoint ] { #category : #hook } -PCScaledRectanglesBenchCase >> newFigureWith: random [ +BlBScaledRectanglesCase >> newFigureWith: random [ ^ BlElement new geometry: BlRectangleGeometry new; @@ -22,7 +22,7 @@ PCScaledRectanglesBenchCase >> newFigureWith: random [ ] { #category : #accessing } -PCScaledRectanglesBenchCase >> scale [ +BlBScaledRectanglesCase >> scale [ ^ 0.75 @ 1.5 ] diff --git a/src/BlocBenchs-Benchs/BlBSolidImagesCase.class.st b/src/BlocBenchs-Benchs/BlBSolidImagesCase.class.st new file mode 100644 index 0000000..88cc4fb --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBSolidImagesCase.class.st @@ -0,0 +1,17 @@ +Class { + #name : #BlBSolidImagesCase, + #superclass : #BlBAbstractImagesCase, + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #hook } +BlBSolidImagesCase >> newImageElementWith: random [ + + | randomIcon | + randomIcon := self newFormWith: random. + + ^ BlElement new + size: randomIcon extent; + background: randomIcon; + yourself +] diff --git a/src/BlocBenchs-Benchs/BlBSolidImagesRawCase.class.st b/src/BlocBenchs-Benchs/BlBSolidImagesRawCase.class.st new file mode 100644 index 0000000..353f97e --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBSolidImagesRawCase.class.st @@ -0,0 +1,76 @@ +Class { + #name : #BlBSolidImagesRawCase, + #superclass : #BlBRawCase, + #traits : 'TBlBAbstractImagesLogic', + #classTraits : 'TBlBAbstractImagesLogic classTrait', + #instVars : [ + 'patterns', + 'random', + 'deltaYPerMS' + ], + #category : #'BlocBenchs-Benchs-Raw' +} + +{ #category : #drawing } +BlBSolidImagesRawCase >> drawOnCairoSurface [ + + | deltaY tmpMatrix patternStream | + self clearCairoSurface. + + deltaY := deltaYPerMS * (lastMS - startMS). + tmpMatrix := AeCairoMatrix new. + patternStream := patterns readStream. + + 1 to: self numberOfColumns do: [ :columnIndex | + | positionX positionY | + positionX := ((self figureOffset x + columnIndex) * self offsetBetweenFigures x) - 380.0. "WHY?" + positionY := self figureOffset y + deltaY. + + 1 to: self numberOfRows do: [ :rowIndex | + | aPattern | + positionY := positionY + self offsetBetweenFigures y. + + aPattern := patternStream next. + "The pattern translation must be negated, as Cairo doc explains." + tmpMatrix beTranslationByX: positionX negated y: positionY negated. + aPattern matrix: tmpMatrix. + + cairoContext + source: aPattern; + paint + + ]] + +] + +{ #category : #hook } +BlBSolidImagesRawCase >> figureOffset [ + + ^ 20 @ 20 +] + +{ #category : #drawing } +BlBSolidImagesRawCase >> setupMainTexture [ + + super setupMainTexture. + + random := self newRandom. + + "Convert from Fraction, since Fraction>>* is slow and at the end, cairo expects a Float" + deltaYPerMS := (self targetTranslation y / self numberOfMilliseconds) asFloat. + + patterns := Array streamContents: [ :stream | + (self numberOfColumns * self numberOfRows) timesRepeat: [ + | aForm aPattern | + aForm := self newFormWith: random. + aPattern := AeCairoSurfacePattern surface: (AeCairoImageSurface fromForm: aForm). + aPattern filter: AeCairoSamplingFilter fast. + stream nextPut: aPattern ] ] + +] + +{ #category : #accessing } +BlBSolidImagesRawCase >> targetTranslation [ + + ^ 0 @ 200 +] diff --git a/src/BlocBenchs-FPS/PCTextBenchCase.class.st b/src/BlocBenchs-Benchs/BlBTextCase.class.st similarity index 56% rename from src/BlocBenchs-FPS/PCTextBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBTextCase.class.st index 90b43f2..e1dd9a7 100644 --- a/src/BlocBenchs-FPS/PCTextBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBTextCase.class.st @@ -1,11 +1,11 @@ Class { - #name : #PCTextBenchCase, - #superclass : #PCTranslatingFiguresBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlBTextCase, + #superclass : #BlBAbstractTranslatingFiguresCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #hook } -PCTextBenchCase >> blTextFor: random [ +BlBTextCase >> blTextFor: random [ ^ (BlRopedText string: (String loremIpsum: 170)) fontSize: 8; @@ -15,13 +15,13 @@ PCTextBenchCase >> blTextFor: random [ ] { #category : #accessing } -PCTextBenchCase >> logicalExtent [ +BlBTextCase >> logicalExtent [ ^ 900 @ 900 ] { #category : #hook } -PCTextBenchCase >> newFigureWith: random [ +BlBTextCase >> newFigureWith: random [ ^ BlTextElement new text: (self blTextFor: random); @@ -30,19 +30,19 @@ PCTextBenchCase >> newFigureWith: random [ ] { #category : #accessing } -PCTextBenchCase >> numberOfFigures [ +BlBTextCase >> numberOfFigures [ ^ 100 ] { #category : #hook } -PCTextBenchCase >> offsetBetweenFigures [ +BlBTextCase >> offsetBetweenFigures [ ^ 0 @ 9 ] { #category : #accessing } -PCTextBenchCase >> targetTranslation [ +BlBTextCase >> targetTranslation [ ^ 0 @ 100 ] diff --git a/src/BlocBenchs-FPS/PCTranslucentEllipsesBenchCase.class.st b/src/BlocBenchs-Benchs/BlBTranslucentEllipsesCase.class.st similarity index 58% rename from src/BlocBenchs-FPS/PCTranslucentEllipsesBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBTranslucentEllipsesCase.class.st index 1f24715..aca06a6 100644 --- a/src/BlocBenchs-FPS/PCTranslucentEllipsesBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBTranslucentEllipsesCase.class.st @@ -1,11 +1,11 @@ Class { - #name : #PCTranslucentEllipsesBenchCase, - #superclass : #PCTranslatingFiguresBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlBTranslucentEllipsesCase, + #superclass : #BlBAbstractTranslatingFiguresCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #accessing } -PCTranslucentEllipsesBenchCase >> figureExtent: aRandom [ +BlBTranslucentEllipsesCase >> figureExtent: aRandom [ ^ Point x: (aRandom nextBetween: 20 and: 80) @@ -13,7 +13,7 @@ PCTranslucentEllipsesBenchCase >> figureExtent: aRandom [ ] { #category : #hook } -PCTranslucentEllipsesBenchCase >> newFigureWith: random [ +BlBTranslucentEllipsesCase >> newFigureWith: random [ ^ BlElement new border: (BlBorder diff --git a/src/BlocBenchs-FPS/PCTranslucentImagesBenchCase.class.st b/src/BlocBenchs-Benchs/BlBTranslucentImagesCase.class.st similarity index 57% rename from src/BlocBenchs-FPS/PCTranslucentImagesBenchCase.class.st rename to src/BlocBenchs-Benchs/BlBTranslucentImagesCase.class.st index 13a368b..27caafb 100644 --- a/src/BlocBenchs-FPS/PCTranslucentImagesBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBTranslucentImagesCase.class.st @@ -1,11 +1,11 @@ Class { - #name : #PCTranslucentImagesBenchCase, - #superclass : #PCImagesBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlBTranslucentImagesCase, + #superclass : #BlBAbstractImagesCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #'instance creation' } -PCTranslucentImagesBenchCase >> newImageElementWith: random [ +BlBTranslucentImagesCase >> newImageElementWith: random [ | randomIcon | randomIcon := self newFormWith: random. diff --git a/src/BlocBenchs-FPS/PCRoundedRectanglesBenchCase.class.st b/src/BlocBenchs-Benchs/BlRoundedRectanglesCase.class.st similarity index 51% rename from src/BlocBenchs-FPS/PCRoundedRectanglesBenchCase.class.st rename to src/BlocBenchs-Benchs/BlRoundedRectanglesCase.class.st index f33b0fa..79d07d6 100644 --- a/src/BlocBenchs-FPS/PCRoundedRectanglesBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlRoundedRectanglesCase.class.st @@ -1,17 +1,17 @@ Class { - #name : #PCRoundedRectanglesBenchCase, - #superclass : #PCTranslatingFiguresBenchCase, - #category : #'BlocBenchs-FPS-Cases' + #name : #BlRoundedRectanglesCase, + #superclass : #BlBAbstractTranslatingFiguresCase, + #category : #'BlocBenchs-Benchs-Bloc' } { #category : #accessing } -PCRoundedRectanglesBenchCase >> figureExtent [ +BlRoundedRectanglesCase >> figureExtent [ ^ 80.0 asPoint ] { #category : #hook } -PCRoundedRectanglesBenchCase >> newFigureWith: random [ +BlRoundedRectanglesCase >> newFigureWith: random [ ^ BlElement new background: (Color random: random); diff --git a/src/BlocBenchs-Benchs/TBlBAbstractImagesLogic.trait.st b/src/BlocBenchs-Benchs/TBlBAbstractImagesLogic.trait.st new file mode 100644 index 0000000..d3004c5 --- /dev/null +++ b/src/BlocBenchs-Benchs/TBlBAbstractImagesLogic.trait.st @@ -0,0 +1,40 @@ +Trait { + #name : #TBlBAbstractImagesLogic, + #category : #'BlocBenchs-Benchs' +} + +{ #category : #hook } +TBlBAbstractImagesLogic >> newFormWith: random [ + + ^ Smalltalk ui icons icons atRandom: random +] + +{ #category : #accessing } +TBlBAbstractImagesLogic >> numberOfColumns [ + + ^ 30 +] + +{ #category : #accessing } +TBlBAbstractImagesLogic >> numberOfFigures [ + + ^ self numberOfColumns +] + +{ #category : #accessing } +TBlBAbstractImagesLogic >> numberOfRows [ + + ^ 20 +] + +{ #category : #hook } +TBlBAbstractImagesLogic >> offsetBetweenFigures [ + + ^ 20 @ 20 +] + +{ #category : #hook } +TBlBAbstractImagesLogic >> spaceExtent [ + + ^ 700 @ 700 +] diff --git a/src/BlocBenchs-Benchs/TBlBNestedTransformationsLogic.trait.st b/src/BlocBenchs-Benchs/TBlBNestedTransformationsLogic.trait.st new file mode 100644 index 0000000..1e4b13a --- /dev/null +++ b/src/BlocBenchs-Benchs/TBlBNestedTransformationsLogic.trait.st @@ -0,0 +1,40 @@ +Trait { + #name : #TBlBNestedTransformationsLogic, + #category : #'BlocBenchs-Benchs' +} + +{ #category : #accessing } +TBlBNestedTransformationsLogic >> figureExtent [ + + ^ 600.0 asPoint +] + +{ #category : #hook } +TBlBNestedTransformationsLogic >> figureOffset [ + + ^ 50.0 asPoint +] + +{ #category : #accessing } +TBlBNestedTransformationsLogic >> logicalExtent [ + + ^ 750 @ 750 +] + +{ #category : #accessing } +TBlBNestedTransformationsLogic >> numberOfFigures [ + + ^ 50 +] + +{ #category : #accessing } +TBlBNestedTransformationsLogic >> targetRelativeRotation [ + + ^ 5.0 +] + +{ #category : #accessing } +TBlBNestedTransformationsLogic >> targetRelativeScale [ + + ^ 0.9 +] diff --git a/src/BlocBenchs-Core/BlBBlocCase.class.st b/src/BlocBenchs-Core/BlBBlocCase.class.st index b1499a3..db8018e 100644 --- a/src/BlocBenchs-Core/BlBBlocCase.class.st +++ b/src/BlocBenchs-Core/BlBBlocCase.class.st @@ -10,6 +10,12 @@ BlBBlocCase class >> isAbstract [ ^ self == BlBBlocCase ] +{ #category : #utils } +BlBBlocCase >> angleInDegreesWith: random [ + + ^ random nextInteger: 360 +] + { #category : #accessing } BlBBlocCase >> defaultRunnerClass [ diff --git a/src/BlocBenchs-Core/BlBCase.class.st b/src/BlocBenchs-Core/BlBCase.class.st index 24c8a6e..a7a8e47 100644 --- a/src/BlocBenchs-Core/BlBCase.class.st +++ b/src/BlocBenchs-Core/BlBCase.class.st @@ -60,6 +60,12 @@ BlBCase >> defaultDuration [ ^ 10 seconds ] +{ #category : #accessing } +BlBCase >> defaultLabel [ + + ^ self class name asString +] + { #category : #accessing } BlBCase >> duration [ @@ -75,7 +81,7 @@ BlBCase >> duration: aDuration [ { #category : #accessing } BlBCase >> label [ - ^ label ifNil: [ self class name ] + ^ label ifNil: [ self defaultLabel ] ] { #category : #accessing } diff --git a/src/BlocBenchs-Core/BlBRawCase.class.st b/src/BlocBenchs-Core/BlBRawCase.class.st index 6016137..213dc50 100644 --- a/src/BlocBenchs-Core/BlBRawCase.class.st +++ b/src/BlocBenchs-Core/BlBRawCase.class.st @@ -16,6 +16,12 @@ Class { #category : #'BlocBenchs-Core-Core' } +{ #category : #running } +BlBRawCase class >> isAbstract [ + + ^ self == BlBRawCase +] + { #category : #running } BlBRawCase >> beforeRunRenderer: aSDLRenderer window: aSDLWindow [ @@ -99,6 +105,12 @@ BlBRawCase >> initialize [ mainTextureStrategyClass := PCUpdateStaticTextureStrategy ] +{ #category : #accessing } +BlBRawCase >> numberOfMilliseconds [ + + ^ self duration asMilliSeconds +] + { #category : #accessing } BlBRawCase >> position [ @@ -113,6 +125,10 @@ BlBRawCase >> presentOnWindow [ present ] +{ #category : #initialization } +BlBRawCase >> resetAnimation [ +] + { #category : #'drawing - steps' } BlBRawCase >> setupMainTexture [ diff --git a/src/BlocBenchs-FPS/PCCirclesBenchCase.class.st b/src/BlocBenchs-FPS/PCCirclesBenchCase.class.st index a8021d0..02cd583 100644 --- a/src/BlocBenchs-FPS/PCCirclesBenchCase.class.st +++ b/src/BlocBenchs-FPS/PCCirclesBenchCase.class.st @@ -3,38 +3,3 @@ Class { #superclass : #PCTranslatingFiguresBenchCase, #category : #'BlocBenchs-FPS-Cases' } - -{ #category : #hook } -PCCirclesBenchCase >> newFigureWith: random [ - - ^ BlElement new - geometry: BlCircleGeometry new; - size: self radius * 2; - in:[ :me | self prepare: me with: random ]; - yourself - -] - -{ #category : #accessing } -PCCirclesBenchCase >> numberOfFigures [ - - ^ 100 -] - -{ #category : #accessing } -PCCirclesBenchCase >> offsetBetweenFigures [ - - ^ 6 @ 0 -] - -{ #category : #hook } -PCCirclesBenchCase >> prepare: anElement with: random [ - - ^ self subclassResponsibility -] - -{ #category : #accessing } -PCCirclesBenchCase >> radius [ - - ^ 50.0 asPoint -] diff --git a/src/BlocBenchs-FPS/PCGradientCirclesBenchCase.class.st b/src/BlocBenchs-FPS/PCGradientCirclesBenchCase.class.st deleted file mode 100644 index bc55e50..0000000 --- a/src/BlocBenchs-FPS/PCGradientCirclesBenchCase.class.st +++ /dev/null @@ -1,62 +0,0 @@ -" -I'm a bench case for gradient fills. - -My main parameters is ""numberOfStops"". -" -Class { - #name : #PCGradientCirclesBenchCase, - #superclass : #PCCirclesBenchCase, - #instVars : [ - 'numberOfStops' - ], - #category : #'BlocBenchs-FPS-Cases' -} - -{ #category : #hook } -PCGradientCirclesBenchCase >> initialize [ - - super initialize. - - numberOfStops := 3. -] - -{ #category : #accessing } -PCGradientCirclesBenchCase >> label [ - - ^ '{1} w/ {2} stops' format: { - super label. - numberOfStops } -] - -{ #category : #hook } -PCGradientCirclesBenchCase >> newGradient: random [ - - ^ self subclassResponsibility -] - -{ #category : #hook } -PCGradientCirclesBenchCase >> newStops: random [ - - ^ (0.0 to: 1.0 by: (1/(numberOfStops-1))) - collect: [ :each | each -> (Color random: random) ]. - -] - -{ #category : #accessing } -PCGradientCirclesBenchCase >> numberOfStops [ - - ^ numberOfStops -] - -{ #category : #accessing } -PCGradientCirclesBenchCase >> numberOfStops: aCollection [ - "Establish the gradient stops, in the form: { 0.0 -> Color black. 1.0 -> Color white }" - - numberOfStops := aCollection -] - -{ #category : #hook } -PCGradientCirclesBenchCase >> prepare: anElement with: random [ - - anElement background: (self newGradient: random) -] diff --git a/src/BlocBenchs-FPS/PCImagesBenchCase.class.st b/src/BlocBenchs-FPS/PCImagesBenchCase.class.st deleted file mode 100644 index 7a96fdd..0000000 --- a/src/BlocBenchs-FPS/PCImagesBenchCase.class.st +++ /dev/null @@ -1,63 +0,0 @@ -Class { - #name : #PCImagesBenchCase, - #superclass : #PCTranslatingFiguresBenchCase, - #category : #'BlocBenchs-FPS-Cases' -} - -{ #category : #accessing } -PCImagesBenchCase >> logicalExtent [ - - ^ 700 @ 700 -] - -{ #category : #hook } -PCImagesBenchCase >> 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 } -PCImagesBenchCase >> newFormWith: random [ - - ^ Smalltalk ui icons icons atRandom: random -] - -{ #category : #hook } -PCImagesBenchCase >> newImageElementWith: random [ - - ^ self subclassResponsibility -] - -{ #category : #accessing } -PCImagesBenchCase >> numberOfColumns [ - - ^ 30 -] - -{ #category : #accessing } -PCImagesBenchCase >> numberOfFigures [ - - ^ self numberOfColumns -] - -{ #category : #accessing } -PCImagesBenchCase >> numberOfRows [ - - ^ 20 -] - -{ #category : #hook } -PCImagesBenchCase >> offsetBetweenFigures [ - - ^ 20 @ 20 -] diff --git a/src/BlocBenchs-FPS/PCLinearGradientCirclesBenchCase.class.st b/src/BlocBenchs-FPS/PCLinearGradientCirclesBenchCase.class.st deleted file mode 100644 index dc22756..0000000 --- a/src/BlocBenchs-FPS/PCLinearGradientCirclesBenchCase.class.st +++ /dev/null @@ -1,20 +0,0 @@ -" -I'm a bench case for linear gradients. - -See my superclass comment. -" -Class { - #name : #PCLinearGradientCirclesBenchCase, - #superclass : #PCGradientCirclesBenchCase, - #category : #'BlocBenchs-FPS-Cases' -} - -{ #category : #hook } -PCLinearGradientCirclesBenchCase >> newGradient: random [ - - ^ BlLinearGradientPaint new - start: 0 asPoint; - end: 2 * self radius; - stops: (self newStops: random); - yourself. -] diff --git a/src/BlocBenchs-FPS/PCRadialGradientCirclesBenchCase.class.st b/src/BlocBenchs-FPS/PCRadialGradientCirclesBenchCase.class.st deleted file mode 100644 index 615ff99..0000000 --- a/src/BlocBenchs-FPS/PCRadialGradientCirclesBenchCase.class.st +++ /dev/null @@ -1,20 +0,0 @@ -" -I'm a bench case for radial gradients. - -See my superclass comment. -" -Class { - #name : #PCRadialGradientCirclesBenchCase, - #superclass : #PCGradientCirclesBenchCase, - #category : #'BlocBenchs-FPS-Cases' -} - -{ #category : #'instance creation' } -PCRadialGradientCirclesBenchCase >> newGradient: random [ - - ^ BlRadialGradientPaint new - center: self radius; - radius: self radius x; - stops: (self newStops: random); - yourself. -] diff --git a/src/BlocBenchs-FPS/PCSolidImagesBenchCase.class.st b/src/BlocBenchs-FPS/PCSolidImagesBenchCase.class.st deleted file mode 100644 index 0e3b991..0000000 --- a/src/BlocBenchs-FPS/PCSolidImagesBenchCase.class.st +++ /dev/null @@ -1,23 +0,0 @@ -Class { - #name : #PCSolidImagesBenchCase, - #superclass : #PCImagesBenchCase, - #category : #'BlocBenchs-FPS-Cases' -} - -{ #category : #hook } -PCSolidImagesBenchCase >> newImageElementWith: random [ - - | randomIcon | - randomIcon := self newFormWith: random. - - ^ BlElement new - size: randomIcon extent; - background: randomIcon; - yourself -] - -{ #category : #'instance creation' } -PCSolidImagesBenchCase >> newRawSDLCairoWindow [ - - ^ PCSolidImagesWindow newWith: self -] diff --git a/src/BlocBenchs-FPS/PCSolidImagesWindow.class.st b/src/BlocBenchs-FPS/PCSolidImagesWindow.class.st deleted file mode 100644 index 8136fd5..0000000 --- a/src/BlocBenchs-FPS/PCSolidImagesWindow.class.st +++ /dev/null @@ -1,55 +0,0 @@ -Class { - #name : #PCSolidImagesWindow, - #superclass : #PCTranslatingFiguresWindow, - #instVars : [ - 'patterns' - ], - #category : #'BlocBenchs-FPS-Raw' -} - -{ #category : #drawing } -PCSolidImagesWindow >> drawOnCairoSurface [ - - | deltaY tmpMatrix patternStream | - super drawOnCairoSurface. - - deltaY := deltaYPerMS * (lastMS - startMS). - tmpMatrix := AeCairoMatrix new. - patternStream := patterns readStream. - - 1 to: case numberOfColumns do: [ :columnIndex | - | positionX positionY | - positionX := ((case figureOffset x + columnIndex) * case offsetBetweenFigures x) - 380.0. "WHY?" - positionY := case figureOffset y + deltaY. - - 1 to: case numberOfRows do: [ :rowIndex | - | aPattern | - positionY := positionY + case offsetBetweenFigures y. - - aPattern := patternStream next. - "The pattern translation must be negated, as Cairo doc explains." - tmpMatrix beTranslationByX: positionX negated y: positionY negated. - aPattern matrix: tmpMatrix. - - cairoContext - source: aPattern; - paint - - ]] - -] - -{ #category : #drawing } -PCSolidImagesWindow >> resetAnimation [ - - super resetAnimation. - - patterns := Array streamContents: [ :stream | - (case numberOfColumns * case numberOfRows) timesRepeat: [ - | aForm aPattern | - aForm := case newFormWith: random. - aPattern := AeCairoSurfacePattern surface: (AeCairoImageSurface fromForm: aForm). - aPattern filter: AeCairoSamplingFilter fast. - stream nextPut: aPattern ] ] - -] diff --git a/src/BlocBenchs-FPS/PCTranslatingFiguresBenchCase.class.st b/src/BlocBenchs-FPS/PCTranslatingFiguresBenchCase.class.st index f486fc6..b88eed3 100644 --- a/src/BlocBenchs-FPS/PCTranslatingFiguresBenchCase.class.st +++ b/src/BlocBenchs-FPS/PCTranslatingFiguresBenchCase.class.st @@ -23,116 +23,3 @@ PCTranslatingFiguresBenchCase class >> exampleOpenFigureSamples [ show ] ] - -{ #category : #accessing } -PCTranslatingFiguresBenchCase >> figureOffset [ - - ^ 20 @ 20 -] - -{ #category : #initialization } -PCTranslatingFiguresBenchCase >> initialize [ - - super initialize. - - useSingleAnimation := true -] - -{ #category : #accessing } -PCTranslatingFiguresBenchCase >> logicalExtent [ - - ^ 750 @ 350 -] - -{ #category : #hook } -PCTranslatingFiguresBenchCase >> newElement [ - - ^ useSingleAnimation - ifTrue: [ self newElementWithSingleAnimation ] - ifFalse: [ self newElementWithIndependentAnimations ] -] - -{ #category : #hook } -PCTranslatingFiguresBenchCase >> newElementWithIndependentAnimations [ - - | random container | - random := self newRandom. - container := BlElement new - size: self logicalExtent; - 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 } -PCTranslatingFiguresBenchCase >> newElementWithSingleAnimation [ - - | random container | - random := self newRandom. - container := BlElement new - size: self logicalExtent; - 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 } -PCTranslatingFiguresBenchCase >> newFigureWith: random [ - - ^ self subclassResponsibility -] - -{ #category : #examples } -PCTranslatingFiguresBenchCase >> newSampleFigure [ - - ^ self newFigureWith: self newRandom -] - -{ #category : #accessing } -PCTranslatingFiguresBenchCase >> numberOfFigures [ - - ^ 300 -] - -{ #category : #hook } -PCTranslatingFiguresBenchCase >> offsetBetweenFigures [ - - ^ 2 @ 0 -] - -{ #category : #accessing } -PCTranslatingFiguresBenchCase >> targetTranslation [ - - ^ 0 @ 200 -] - -{ #category : #accessing } -PCTranslatingFiguresBenchCase >> useSingleAnimation [ - - ^ useSingleAnimation -] - -{ #category : #accessing } -PCTranslatingFiguresBenchCase >> useSingleAnimation: aBoolean [ - - useSingleAnimation := aBoolean -] From 56099dbf1bc64d7f5b5dc1b95d4b9a09bc949690 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Tue, 3 Dec 2024 14:56:41 +0100 Subject: [PATCH 08/23] Ignoring rules --- .../ManifestBlocBenchsBenchs.class.st | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/BlocBenchs-Benchs/ManifestBlocBenchsBenchs.class.st diff --git a/src/BlocBenchs-Benchs/ManifestBlocBenchsBenchs.class.st b/src/BlocBenchs-Benchs/ManifestBlocBenchsBenchs.class.st new file mode 100644 index 0000000..855a9fc --- /dev/null +++ b/src/BlocBenchs-Benchs/ManifestBlocBenchsBenchs.class.st @@ -0,0 +1,15 @@ +" +Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser +" +Class { + #name : #ManifestBlocBenchsBenchs, + #superclass : #PackageManifest, + #category : #'BlocBenchs-Benchs-Manifest' +} + +{ #category : #'code-critics' } +ManifestBlocBenchsBenchs class >> ruleClassNotReferencedRuleV1FalsePositive [ + + + ^ #(#(#(#RGPackageDefinition #(#'BlocBenchs-Benchs')) #'2024-12-03T13:20:52.64557+01:00') ) +] From 6513804d62cb1d345e7659e0646953c8bb1467b8 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 13 Dec 2024 10:06:09 +0100 Subject: [PATCH 09/23] - Adding version recording - Adding Exporting of resutls --- .../BlBOutskirtsBenchCase.class.st | 10 ++- .../BlBAbstractBenchRunner.class.st | 38 ++++++--- ....class.st => BlBAllocationsMeter.class.st} | 8 +- src/BlocBenchs-Core/BlBCase.class.st | 13 +++ src/BlocBenchs-Core/BlBGCMeter.class.st | 62 +++++++++++++++ src/BlocBenchs-Core/BlBResult.class.st | 46 ++++++++++- src/BlocBenchs-Core/BlBVersionsMeter.class.st | 79 +++++++++++++++++++ 7 files changed, 237 insertions(+), 19 deletions(-) rename src/BlocBenchs-Core/{BlAllocationsMeter.class.st => BlBAllocationsMeter.class.st} (69%) create mode 100644 src/BlocBenchs-Core/BlBGCMeter.class.st create mode 100644 src/BlocBenchs-Core/BlBVersionsMeter.class.st diff --git a/src/BlocBenchs-Benchs/BlBOutskirtsBenchCase.class.st b/src/BlocBenchs-Benchs/BlBOutskirtsBenchCase.class.st index 52cee83..98f37fa 100644 --- a/src/BlocBenchs-Benchs/BlBOutskirtsBenchCase.class.st +++ b/src/BlocBenchs-Benchs/BlBOutskirtsBenchCase.class.st @@ -13,11 +13,17 @@ Class { { #category : #benchmarking } BlBOutskirtsBenchCase class >> benchMatrix [ - ^ super benchMatrix +" ^ super benchMatrix forSelector: #mustClipChildren addOptions: #(true false); forSelector: #outskirts addOptions: { BlOutskirts centered. BlOutskirts inside. BlOutskirts outside }; forSelector: #backgroundColor addOptions: { Color transparent. Color orange. Color green alpha: 0.1. }; - forSelector: #useExplicitBorderPathGeometry addOptions: #(true false) + forSelector: #useExplicitBorderPathGeometry addOptions: #(true false)" + + ^ super benchMatrix + addCase: { #mustClipChildren -> true. #outskirts -> BlOutskirts centered. #backgroundColor -> Color orange. #useExplicitBorderPathGeometry -> true }; + addCase: { #mustClipChildren -> true. #outskirts -> BlOutskirts inside. #backgroundColor -> (Color green alpha: 0.1). #useExplicitBorderPathGeometry -> false }; + addCase: { #mustClipChildren -> true. #outskirts -> BlOutskirts outside. #backgroundColor -> (Color green alpha: 0.1). #useExplicitBorderPathGeometry -> true }; + yourself ] { #category : #hook } diff --git a/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st b/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st index 1e5eca9..a61c069 100644 --- a/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st +++ b/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st @@ -25,8 +25,9 @@ BlBAbstractBenchRunner >> defaultMeters [ ^ { BlBTimeMeter new. - BlAllocationsMeter new. - BlBFFICounterMeter new } + BlBAllocationsMeter new. + BlBGCMeter new. + BlBVersionsMeter new } ] { #category : #'as yet unclassified' } @@ -34,6 +35,19 @@ BlBAbstractBenchRunner >> doRun: aBlBBlocCase [ ^ self subclassResponsibility ] +{ #category : #running } +BlBAbstractBenchRunner >> doRunCase: aCase [ + + [ + self prepareBeforeRun: aCase. + self setDuration: aCase. + self startMeters. + self doRun: aCase. + self stopMeters. + self reportMeters + ] ensure: [ self cleanUpAfterCase: aCase ] +] + { #category : #accessing } BlBAbstractBenchRunner >> duration: aDuration [ duration := aDuration @@ -45,6 +59,11 @@ BlBAbstractBenchRunner >> meters [ ^ meters ifNil: [ meters := self defaultMeters asOrderedCollection ] ] +{ #category : #'as yet unclassified' } +BlBAbstractBenchRunner >> prepareBeforeRun: aBlBCase [ + ^ self subclassResponsibility +] + { #category : #running } BlBAbstractBenchRunner >> reportMeters [ @@ -57,15 +76,12 @@ BlBAbstractBenchRunner >> runCase: aCase [ result := BlBResult new. result initializeFrom: aCase. - ^ [ - self prepareBeforeRun: aCase. - self setDuration: aCase. - self startMeters. - self doRun: aCase. - self stopMeters. - self reportMeters. - result - ] ensure: [ self cleanUpAfterCase: aCase ] + [ self doRunCase: aCase ] + onErrorDo: [ :e | + e freeze. + result error: e ]. + + ^ result ] { #category : #running } diff --git a/src/BlocBenchs-Core/BlAllocationsMeter.class.st b/src/BlocBenchs-Core/BlBAllocationsMeter.class.st similarity index 69% rename from src/BlocBenchs-Core/BlAllocationsMeter.class.st rename to src/BlocBenchs-Core/BlBAllocationsMeter.class.st index 7c10411..16ab270 100644 --- a/src/BlocBenchs-Core/BlAllocationsMeter.class.st +++ b/src/BlocBenchs-Core/BlBAllocationsMeter.class.st @@ -1,5 +1,5 @@ Class { - #name : #BlAllocationsMeter, + #name : #BlBAllocationsMeter, #superclass : #BlBMeter, #instVars : [ 'initialAllocationBytes', @@ -9,7 +9,7 @@ Class { } { #category : #'as yet unclassified' } -BlAllocationsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ +BlBAllocationsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ aBlBResult addField: #allocatedBytes @@ -18,13 +18,13 @@ BlAllocationsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ ] { #category : #'as yet unclassified' } -BlAllocationsMeter >> startMetering: aBlBBlocBenchRunner [ +BlBAllocationsMeter >> startMetering: aBlBBlocBenchRunner [ initialAllocationBytes := Smalltalk vm getParameters at: 34. ] { #category : #'as yet unclassified' } -BlAllocationsMeter >> stopMetering: aBlBBlocBenchRunner [ +BlBAllocationsMeter >> stopMetering: aBlBBlocBenchRunner [ finalAllocationBytes := Smalltalk vm getParameters at: 34. ] diff --git a/src/BlocBenchs-Core/BlBCase.class.st b/src/BlocBenchs-Core/BlBCase.class.st index a7a8e47..993be12 100644 --- a/src/BlocBenchs-Core/BlBCase.class.st +++ b/src/BlocBenchs-Core/BlBCase.class.st @@ -54,6 +54,19 @@ BlBCase class >> run [ ] +{ #category : #'as yet unclassified' } +BlBCase class >> runAllWithResultsIn: aDirectory [ + + | allBenchs result | + aDirectory ensureCreateDirectory. + allBenchs := self benchSuite. + + ^ allBenchs collect: [ :aBench | + result := aBench run. + result serializeResultsInto: aDirectory. + result ] +] + { #category : #'accessing - defaults' } BlBCase >> defaultDuration [ diff --git a/src/BlocBenchs-Core/BlBGCMeter.class.st b/src/BlocBenchs-Core/BlBGCMeter.class.st new file mode 100644 index 0000000..08025e7 --- /dev/null +++ b/src/BlocBenchs-Core/BlBGCMeter.class.st @@ -0,0 +1,62 @@ +Class { + #name : #BlBGCMeter, + #superclass : #BlBMeter, + #instVars : [ + 'finalFullGCCount', + 'initialFullGCCount', + 'finalIncrementalGCCount', + 'initialIncrementalGCCount', + 'initialFullGCTime', + 'initialIncrementalGCTime', + 'finalFullGCTime', + 'finalIncrementalGCTime' + ], + #category : #'BlocBenchs-Core-Core' +} + +{ #category : #'as yet unclassified' } +BlBGCMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + + aBlBResult + addField: #fullGCCount + title: 'Number of Full GCs' + value: finalFullGCCount - initialFullGCCount. + + aBlBResult + addField: #incrementalGCCount + title: 'Number of Incremental GCs' + value: finalIncrementalGCCount - initialIncrementalGCCount . + + aBlBResult + addField: #fullGCTotalTime + title: 'Incremental GC Total Time (in ms)' + value: finalFullGCTime - initialFullGCTime. + + aBlBResult + addField: #incrementalGCTotalTime + title: 'Incremental GC Total Time (in ms)' + value: finalIncrementalGCTime - initialIncrementalGCTime +] + +{ #category : #'as yet unclassified' } +BlBGCMeter >> startMetering: aBlBBlocBenchRunner [ + + "We force a GC to have better statistics" + Smalltalk garbageCollect. + + initialFullGCCount := Smalltalk vm fullGCCount. + initialIncrementalGCCount := Smalltalk vm incrementalGCCount. + initialFullGCTime := Smalltalk vm totalFullGCTime. + initialIncrementalGCTime := Smalltalk vm totalIncrementalGCTime. + +] + +{ #category : #'as yet unclassified' } +BlBGCMeter >> stopMetering: aBlBBlocBenchRunner [ + + finalFullGCCount := Smalltalk vm fullGCCount. + finalIncrementalGCCount := Smalltalk vm incrementalGCCount. + finalFullGCTime := Smalltalk vm totalFullGCTime. + finalIncrementalGCTime := Smalltalk vm totalIncrementalGCTime. + +] diff --git a/src/BlocBenchs-Core/BlBResult.class.st b/src/BlocBenchs-Core/BlBResult.class.st index 998f153..abc5f01 100644 --- a/src/BlocBenchs-Core/BlBResult.class.st +++ b/src/BlocBenchs-Core/BlBResult.class.st @@ -4,11 +4,21 @@ Class { #instVars : [ 'content', 'caseClassName', - 'caseLabel' + 'caseLabel', + 'dateAndTime', + 'id', + 'hasError', + 'error' ], #category : #'BlocBenchs-Core-Core' } +{ #category : #'ston-core' } +BlBResult class >> stonAllInstVarNames [ + + ^ super stonAllInstVarNames copyWithout: #error +] + { #category : #adding } BlBResult >> addField: aFieldName title: aTitle value: aValue [ @@ -21,9 +31,41 @@ BlBResult >> content [ ^ content ifNil: [ content := Dictionary new ] ] +{ #category : #accessing } +BlBResult >> error: anError [ + + error := anError +] + { #category : #initialization } BlBResult >> initializeFrom: aBlBCase [ caseClassName := aBlBCase class name. - caseLabel := aBlBCase label + caseLabel := aBlBCase label. + dateAndTime := DateAndTime now. + id := UUID new asString. + hasError := false. +] + +{ #category : #'as yet unclassified' } +BlBResult >> serializeErrorInto: aDirectory [ + + FLDebuggerStackSerializer + serializeStackFromContext: error signalerContext + toFileNamed: ((aDirectory / id) withExtension: 'fuel') fullName +] + +{ #category : #'as yet unclassified' } +BlBResult >> serializeResultsInto: aDirectory [ + + | stonFile | + + hasError := error isNotNil. + hasError ifTrue: [ self serializeErrorInto: aDirectory ]. + + stonFile := (aDirectory / id) withExtension: 'ston'. + + stonFile writeStreamDo: [ :aStream | + STON put: self onStreamPretty: aStream ]. + ] diff --git a/src/BlocBenchs-Core/BlBVersionsMeter.class.st b/src/BlocBenchs-Core/BlBVersionsMeter.class.st new file mode 100644 index 0000000..b5d345f --- /dev/null +++ b/src/BlocBenchs-Core/BlBVersionsMeter.class.st @@ -0,0 +1,79 @@ +Class { + #name : #BlBVersionsMeter, + #superclass : #BlBMeter, + #category : #'BlocBenchs-Core-Core' +} + +{ #category : #accessing } +BlBVersionsMeter >> imageVersion [ + + ^ SystemVersion current imageVersionString , + String crlf, + SystemVersion current datedVersion +] + +{ #category : #'as yet unclassified' } +BlBVersionsMeter >> osName [ + + ^ OSPlatform current in: [:p | + p platformName , ' ' , p processorArchitecture ] +] + +{ #category : #'as yet unclassified' } +BlBVersionsMeter >> osVersion [ + + ^ OSPlatform current version +] + +{ #category : #'as yet unclassified' } +BlBVersionsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + + aBlBResult + addField: #repositoriesVersions + title: 'Repositories Versions' + value: self repositoriesVersions. + + aBlBResult + addField: #imageVersion + title: 'Pharo Image Version' + value: self imageVersion. + + aBlBResult + addField: #vmVersion + title: 'Pharo VM Version' + value: self vmVersioon. + + aBlBResult + addField: #osName + title: 'Operating System Name' + value: self osName. + + aBlBResult + addField: #osVersion + title: 'Operating System Version' + value: self osVersion. +] + +{ #category : #'as yet unclassified' } +BlBVersionsMeter >> repositoriesVersions [ + + ^ IceRepository registry + reject: [ :e | e location isNil ] + thenCollect: [ :e | {e name. e description} ] +] + +{ #category : #'as yet unclassified' } +BlBVersionsMeter >> startMetering: aBlBBlocBenchRunner [ + +] + +{ #category : #'as yet unclassified' } +BlBVersionsMeter >> stopMetering: aBlBBlocBenchRunner [ + +] + +{ #category : #'as yet unclassified' } +BlBVersionsMeter >> vmVersioon [ + + ^ Smalltalk vm version +] From 485c214da42bf0977786fba563d028ccdddb7042 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 13 Dec 2024 11:31:58 +0100 Subject: [PATCH 10/23] Fixing the printing of mean when empty --- src/BlocBenchs-Core/BlBAllocationsMeter.class.st | 6 +++--- src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st | 14 +++++++++----- src/BlocBenchs-Core/BlBFFICounterMeter.class.st | 6 +++--- src/BlocBenchs-Core/BlBFFILogger.class.st | 6 +++--- src/BlocBenchs-Core/BlBGCMeter.class.st | 6 +++--- src/BlocBenchs-Core/BlBMeter.class.st | 12 +++++++++++- src/BlocBenchs-Core/BlBRawRenderingMeter.class.st | 14 +++++++++----- .../BlBSystemProfilerMeter.class.st | 6 +++--- src/BlocBenchs-Core/BlBTimeMeter.class.st | 6 +++--- src/BlocBenchs-Core/BlBVersionsMeter.class.st | 14 +++++++------- 10 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/BlocBenchs-Core/BlBAllocationsMeter.class.st b/src/BlocBenchs-Core/BlBAllocationsMeter.class.st index 16ab270..613d5e7 100644 --- a/src/BlocBenchs-Core/BlBAllocationsMeter.class.st +++ b/src/BlocBenchs-Core/BlBAllocationsMeter.class.st @@ -8,7 +8,7 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBAllocationsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ aBlBResult @@ -17,13 +17,13 @@ BlBAllocationsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ value: finalAllocationBytes - initialAllocationBytes ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBAllocationsMeter >> startMetering: aBlBBlocBenchRunner [ initialAllocationBytes := Smalltalk vm getParameters at: 34. ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBAllocationsMeter >> stopMetering: aBlBBlocBenchRunner [ finalAllocationBytes := Smalltalk vm getParameters at: 34. diff --git a/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st b/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st index e412641..117fd62 100644 --- a/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st +++ b/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st @@ -4,10 +4,10 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBBlocRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ - | stats fpsSamples | + | stats fpsSamples mean | stats := aBlBBlocBenchRunner space spaceStatistics. fpsSamples := stats fpsSamples allButFirst collect: [:e | e second]. @@ -21,10 +21,14 @@ BlBBlocRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ title: 'Frame Count' value: stats totalFrames. + mean := fpsSamples + ifEmpty: [ 0 ] + ifNotEmpty: [ (MeanConfidenceIntervalPrinter new print: fpsSamples)]. + aBlBResult addField: #fps title: 'FPS mean and error margin (90% confidence level)' - value: (MeanConfidenceIntervalPrinter new print: fpsSamples). + value: mean. aBlBResult addField: #fpsSamples @@ -38,13 +42,13 @@ BlBBlocRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBBlocRenderingMeter >> startMetering: aBlBBlocBenchRunner [ aBlBBlocBenchRunner space enableStatistics ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBBlocRenderingMeter >> stopMetering: aBlBBlocBenchRunner [ diff --git a/src/BlocBenchs-Core/BlBFFICounterMeter.class.st b/src/BlocBenchs-Core/BlBFFICounterMeter.class.st index e00966d..041ae9f 100644 --- a/src/BlocBenchs-Core/BlBFFICounterMeter.class.st +++ b/src/BlocBenchs-Core/BlBFFICounterMeter.class.st @@ -7,7 +7,7 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBFFICounterMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ aBlBResult @@ -22,7 +22,7 @@ BlBFFICounterMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBFFICounterMeter >> startMetering: aBlBBlocBenchRunner [ "Ensure prepared" @@ -33,7 +33,7 @@ BlBFFICounterMeter >> startMetering: aBlBBlocBenchRunner [ TFLFunctionCounter start. ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBFFICounterMeter >> stopMetering: aBlBBenchRunner [ "Extract relevant information of the global logger, and reset it." diff --git a/src/BlocBenchs-Core/BlBFFILogger.class.st b/src/BlocBenchs-Core/BlBFFILogger.class.st index a983cfd..6821793 100644 --- a/src/BlocBenchs-Core/BlBFFILogger.class.st +++ b/src/BlocBenchs-Core/BlBFFILogger.class.st @@ -7,7 +7,7 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBFFILogger >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ aBlBResult @@ -16,7 +16,7 @@ BlBFFILogger >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ value: loggerCopy ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBFFILogger >> startMetering: aBlBBlocBenchRunner [ "Ensure prepared" @@ -28,7 +28,7 @@ BlBFFILogger >> startMetering: aBlBBlocBenchRunner [ TFLCallLogger instance start ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBFFILogger >> stopMetering: aBlBBlocBenchRunner [ "Store a copy of the global logger, and reset it." diff --git a/src/BlocBenchs-Core/BlBGCMeter.class.st b/src/BlocBenchs-Core/BlBGCMeter.class.st index 08025e7..0d7421d 100644 --- a/src/BlocBenchs-Core/BlBGCMeter.class.st +++ b/src/BlocBenchs-Core/BlBGCMeter.class.st @@ -14,7 +14,7 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBGCMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ aBlBResult @@ -38,7 +38,7 @@ BlBGCMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ value: finalIncrementalGCTime - initialIncrementalGCTime ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBGCMeter >> startMetering: aBlBBlocBenchRunner [ "We force a GC to have better statistics" @@ -51,7 +51,7 @@ BlBGCMeter >> startMetering: aBlBBlocBenchRunner [ ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBGCMeter >> stopMetering: aBlBBlocBenchRunner [ finalFullGCCount := Smalltalk vm fullGCCount. diff --git a/src/BlocBenchs-Core/BlBMeter.class.st b/src/BlocBenchs-Core/BlBMeter.class.st index b8a8896..f7c9ea7 100644 --- a/src/BlocBenchs-Core/BlBMeter.class.st +++ b/src/BlocBenchs-Core/BlBMeter.class.st @@ -4,7 +4,17 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } +BlBMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ + +] + +{ #category : #mettering } BlBMeter >> startMetering: aBlBBlocBenchRunner [ ^ self subclassResponsibility ] + +{ #category : #mettering } +BlBMeter >> stopMetering: aBlBBlocBenchRunner [ + ^ self subclassResponsibility +] diff --git a/src/BlocBenchs-Core/BlBRawRenderingMeter.class.st b/src/BlocBenchs-Core/BlBRawRenderingMeter.class.st index a191e4d..5907554 100644 --- a/src/BlocBenchs-Core/BlBRawRenderingMeter.class.st +++ b/src/BlocBenchs-Core/BlBRawRenderingMeter.class.st @@ -8,10 +8,10 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBRawRenderingMeter >> reportResultsFrom: aBlBRawBenchRunner in: aBlBResult [ - | fpsSamples | + | fpsSamples mean | fpsSamples := aBlBRawBenchRunner fpsSamples allButFirst collect: [:e | e second]. @@ -25,10 +25,14 @@ BlBRawRenderingMeter >> reportResultsFrom: aBlBRawBenchRunner in: aBlBResult [ title: 'Frame Count' value: aBlBRawBenchRunner totalFrames. + mean := fpsSamples + ifEmpty: [ 0 ] + ifNotEmpty: [ (MeanConfidenceIntervalPrinter new print: fpsSamples)]. + aBlBResult addField: #fps title: 'FPS mean and error margin (90% confidence level)' - value: (MeanConfidenceIntervalPrinter new print: fpsSamples). + value: mean. aBlBResult addField: #fpsSamples @@ -37,13 +41,13 @@ BlBRawRenderingMeter >> reportResultsFrom: aBlBRawBenchRunner in: aBlBResult [ ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBRawRenderingMeter >> startMetering: aBlBBlocBenchRunner [ initialTime := Time millisecondClockValue ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBRawRenderingMeter >> stopMetering: aBlBBlocBenchRunner [ finalTime := Time millisecondClockValue diff --git a/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st b/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st index ece0e8d..1d9bce7 100644 --- a/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st +++ b/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st @@ -7,7 +7,7 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBSystemProfilerMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ | flameGraph | @@ -42,14 +42,14 @@ BlBSystemProfilerMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBSystemProfilerMeter >> startMetering: aBlBBlocBenchRunner [ profiler := AndreasSystemProfiler new. profiler startProfiling ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBSystemProfilerMeter >> stopMetering: aBlBBlocBenchRunner [ profiler stopProfiling diff --git a/src/BlocBenchs-Core/BlBTimeMeter.class.st b/src/BlocBenchs-Core/BlBTimeMeter.class.st index f904008..72439bb 100644 --- a/src/BlocBenchs-Core/BlBTimeMeter.class.st +++ b/src/BlocBenchs-Core/BlBTimeMeter.class.st @@ -8,7 +8,7 @@ Class { #category : #'BlocBenchs-Core-Core' } -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBTimeMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ aBlBResult @@ -18,13 +18,13 @@ BlBTimeMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBTimeMeter >> startMetering: aBlBBlocBenchRunner [ initialTime := Time millisecondClockValue ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBTimeMeter >> stopMetering: aBlBBlocBenchRunner [ finalTime := Time millisecondClockValue diff --git a/src/BlocBenchs-Core/BlBVersionsMeter.class.st b/src/BlocBenchs-Core/BlBVersionsMeter.class.st index b5d345f..af6e221 100644 --- a/src/BlocBenchs-Core/BlBVersionsMeter.class.st +++ b/src/BlocBenchs-Core/BlBVersionsMeter.class.st @@ -12,20 +12,20 @@ BlBVersionsMeter >> imageVersion [ SystemVersion current datedVersion ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } BlBVersionsMeter >> osName [ ^ OSPlatform current in: [:p | p platformName , ' ' , p processorArchitecture ] ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } BlBVersionsMeter >> osVersion [ ^ OSPlatform current version ] -{ #category : #'as yet unclassified' } +{ #category : #reporting } BlBVersionsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ aBlBResult @@ -54,7 +54,7 @@ BlBVersionsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ value: self osVersion. ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } BlBVersionsMeter >> repositoriesVersions [ ^ IceRepository registry @@ -62,17 +62,17 @@ BlBVersionsMeter >> repositoriesVersions [ thenCollect: [ :e | {e name. e description} ] ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBVersionsMeter >> startMetering: aBlBBlocBenchRunner [ ] -{ #category : #'as yet unclassified' } +{ #category : #mettering } BlBVersionsMeter >> stopMetering: aBlBBlocBenchRunner [ ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } BlBVersionsMeter >> vmVersioon [ ^ Smalltalk vm version From 87c204b589f70f17db7d2fbd074148d4c7ec453d Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 13 Dec 2024 11:49:20 +0100 Subject: [PATCH 11/23] Fixing baseline --- src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st b/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st index 9ca95a5..7388c6d 100644 --- a/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st +++ b/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st @@ -31,7 +31,11 @@ BaselineOfBlocBenchs >> baseline: spec [ package: 'BlocBenchs-Alexandrie' with: [ spec requires: #('Toplo' 'BlocBenchs-Printing' 'BlocBenchs-FPS') ]; package: 'BlocBenchs-Tests' - with: [ spec requires: #('BlocBenchs-SDL' 'BlocBenchs-Alexandrie' 'BlocBenchs-Old' 'BlocBenchs-FPS') ] + with: [ spec requires: #('BlocBenchs-SDL' 'BlocBenchs-Alexandrie' 'BlocBenchs-Old' 'BlocBenchs-FPS') ]; + package: 'BlocBenchs-Core' + with: [ spec requires: #('Bloc' 'BlocBenchs-FPS' 'FFICallLogger' 'SaucoPerfMeter' 'SDLExperiments') ]; + package: 'BlocBenchs-Benchs' + with: [ spec requires: #('Toplo' 'BlocBenchs-Core' 'BlocTutorialsBoids') ] ] ] From 8a2b408250d71fcc3711984640deb87c3cf4078f Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 13 Dec 2024 12:05:05 +0100 Subject: [PATCH 12/23] Fixing Baseline --- src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st b/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st index 7388c6d..970fcda 100644 --- a/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st +++ b/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st @@ -12,7 +12,7 @@ BaselineOfBlocBenchs >> baseline: spec [ for: #common do: [ self - "declareBlocOn: spec;" + declareBlocOn: spec; declareBoidsOn: spec; declareToploOn: spec; declareFFICallLoggerOn: spec; From 54bd4f593c9f5f617541c53168d87f9fe3f6494d Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Mon, 16 Dec 2024 10:27:03 +0100 Subject: [PATCH 13/23] Removing log message --- src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st b/src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st index c70f1c1..78f575c 100644 --- a/src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st +++ b/src/BlocBenchs-Benchs/BlBKeysCursorMoveTextEditorCase.class.st @@ -27,7 +27,6 @@ BlBKeysCursorMoveTextEditorCase >> dispatchEvent [ { BlKeyDownEvent new. BlKeyUpEvent new } do: [ :anEvent | anEvent key: key. - 'aaa' traceCr. MorphicRenderLoop new doOneCycle. editorElement space dispatchEventWithTimestamp: anEvent ] ] From 360ffd172c1d2101ec4be3e876985e2ab4c7600e Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Mon, 16 Dec 2024 10:31:07 +0100 Subject: [PATCH 14/23] Adding logs --- src/BlocBenchs-Core/BlBCase.class.st | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/BlocBenchs-Core/BlBCase.class.st b/src/BlocBenchs-Core/BlBCase.class.st index 993be12..cbfd289 100644 --- a/src/BlocBenchs-Core/BlBCase.class.st +++ b/src/BlocBenchs-Core/BlBCase.class.st @@ -61,9 +61,11 @@ BlBCase class >> runAllWithResultsIn: aDirectory [ aDirectory ensureCreateDirectory. allBenchs := self benchSuite. - ^ allBenchs collect: [ :aBench | + ^ allBenchs collectWithIndex: [ :aBench : index| + ('Running {1} / {2}...' format: { index. allBenchs size }) trace. result := aBench run. result serializeResultsInto: aDirectory. + ' Ended' traceCr. result ] ] From bfb6bf6791a0b3b7d679771896dcbddfad9ecbf4 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Mon, 16 Dec 2024 11:52:14 +0100 Subject: [PATCH 15/23] Adding missing method --- src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st | 7 ++++++- src/BlocBenchs-Compatibility-P11/BlockClosure.extension.st | 7 +++++++ src/BlocBenchs-Compatibility-P11/package.st | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/BlocBenchs-Compatibility-P11/BlockClosure.extension.st create mode 100644 src/BlocBenchs-Compatibility-P11/package.st diff --git a/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st b/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st index 970fcda..4bb0ab3 100644 --- a/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st +++ b/src/BaselineOfBlocBenchs/BaselineOfBlocBenchs.class.st @@ -36,7 +36,12 @@ BaselineOfBlocBenchs >> baseline: spec [ with: [ spec requires: #('Bloc' 'BlocBenchs-FPS' 'FFICallLogger' 'SaucoPerfMeter' 'SDLExperiments') ]; package: 'BlocBenchs-Benchs' with: [ spec requires: #('Toplo' 'BlocBenchs-Core' 'BlocTutorialsBoids') ] - ] + ]. + + spec for: #'pharo11.x' + do: [ + spec package: 'BlocBenchs-Compatibility-P11'. + ] ] { #category : #'external projects' } diff --git a/src/BlocBenchs-Compatibility-P11/BlockClosure.extension.st b/src/BlocBenchs-Compatibility-P11/BlockClosure.extension.st new file mode 100644 index 0000000..69d7685 --- /dev/null +++ b/src/BlocBenchs-Compatibility-P11/BlockClosure.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #BlockClosure } + +{ #category : #'*BlocBenchs-Compatibility-P11' } +BlockClosure >> millisecondsToRun [ + + ^ Time millisecondsToRun: self +] diff --git a/src/BlocBenchs-Compatibility-P11/package.st b/src/BlocBenchs-Compatibility-P11/package.st new file mode 100644 index 0000000..50a02a7 --- /dev/null +++ b/src/BlocBenchs-Compatibility-P11/package.st @@ -0,0 +1 @@ +Package { #name : #'BlocBenchs-Compatibility-P11' } From 59993bb5b0214956db340c2d4854cae2addd2ca1 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Mon, 16 Dec 2024 15:09:53 +0100 Subject: [PATCH 16/23] Adding Result Grapher and handling of resutls --- .../BlBCompositionCase.class.st | 6 +- src/BlocBenchs-Core/BlBCase.class.st | 5 +- src/BlocBenchs-Core/BlBResult.class.st | 34 ++++++++++ .../BlBResultsGrapher.class.st | 63 +++++++++++++++++++ 4 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 src/BlocBenchs-Core/BlBResultsGrapher.class.st diff --git a/src/BlocBenchs-Benchs/BlBCompositionCase.class.st b/src/BlocBenchs-Benchs/BlBCompositionCase.class.st index a9d4ed2..f430315 100644 --- a/src/BlocBenchs-Benchs/BlBCompositionCase.class.st +++ b/src/BlocBenchs-Benchs/BlBCompositionCase.class.st @@ -13,8 +13,10 @@ Class { BlBCompositionCase class >> benchMatrix [ ^ ParametrizedTestMatrix new - addCase: { #label -> 'BlBCompositionCase without using composition'. #useSingleComposition -> false}; - addCase: { #label -> 'BlBCompositionCase without using composition'. #useSingleComposition -> true}; + addCase: { #label -> 'BlBCompositionCase without using composition useSingleComposition: false'. + #useSingleComposition -> false}; + addCase: { #label -> 'BlBCompositionCase without using composition useSingleComposition: true'. + #useSingleComposition -> true}; yourself ] diff --git a/src/BlocBenchs-Core/BlBCase.class.st b/src/BlocBenchs-Core/BlBCase.class.st index cbfd289..e662e61 100644 --- a/src/BlocBenchs-Core/BlBCase.class.st +++ b/src/BlocBenchs-Core/BlBCase.class.st @@ -62,10 +62,9 @@ BlBCase class >> runAllWithResultsIn: aDirectory [ allBenchs := self benchSuite. ^ allBenchs collectWithIndex: [ :aBench : index| - ('Running {1} / {2}...' format: { index. allBenchs size }) trace. - result := aBench run. + Stdio stdout << ('Running {1} / {2}...' format: { index. allBenchs size }). result := aBench run. result serializeResultsInto: aDirectory. - ' Ended' traceCr. + Stdio stdout << ' Ended'; crlf; flush. result ] ] diff --git a/src/BlocBenchs-Core/BlBResult.class.st b/src/BlocBenchs-Core/BlBResult.class.st index abc5f01..0d98fc8 100644 --- a/src/BlocBenchs-Core/BlBResult.class.st +++ b/src/BlocBenchs-Core/BlBResult.class.st @@ -25,6 +25,11 @@ BlBResult >> addField: aFieldName title: aTitle value: aValue [ self content at: aFieldName put: { aTitle. aValue } ] +{ #category : #accessing } +BlBResult >> caseLabel [ + ^ caseLabel +] + { #category : #accessing } BlBResult >> content [ @@ -37,6 +42,22 @@ BlBResult >> error: anError [ error := anError ] +{ #category : #accessing } +BlBResult >> fpsSamples [ + + ^ (content at: #fpsSamples) second in: [ :anOrderedCollection | + anOrderedCollection + ifEmpty: [ anOrderedCollection ] + ifNotEmpty: [ + anOrderedCollection allButFirst collect: [ :e | e second ] ] ] +] + +{ #category : #accessing } +BlBResult >> imageVersion [ + + ^ (content at: #imageVersion) second. +] + { #category : #initialization } BlBResult >> initializeFrom: aBlBCase [ @@ -69,3 +90,16 @@ BlBResult >> serializeResultsInto: aDirectory [ STON put: self onStreamPretty: aStream ]. ] + +{ #category : #accessing } +BlBResult >> shortImageVersion [ + + | fullImageVersion parts | + fullImageVersion := self imageVersion. + + parts := (fullImageVersion allButFirst: 'Pharo-' size) splitOn: [ :e | + #( $. $+ ) includes: e ]. + + ^ '{1}.{2}.{3} build {6}' format: parts. + +] diff --git a/src/BlocBenchs-Core/BlBResultsGrapher.class.st b/src/BlocBenchs-Core/BlBResultsGrapher.class.st new file mode 100644 index 0000000..ebcfeb0 --- /dev/null +++ b/src/BlocBenchs-Core/BlBResultsGrapher.class.st @@ -0,0 +1,63 @@ +Class { + #name : #BlBResultsGrapher, + #superclass : #Object, + #instVars : [ + 'resultsDirectory', + 'results', + 'groups' + ], + #category : #'BlocBenchs-Core-Core' +} + +{ #category : #'as yet unclassified' } +BlBResultsGrapher >> ensureGroups [ + + ^ groups ifNil: [ groups := results groupedBy: [ :e | e caseLabel ] ] +] + +{ #category : #'as yet unclassified' } +BlBResultsGrapher >> ensureResults [ + + results ifNotNil: [ ^ results ]. + + results := (resultsDirectory glob: [ :e | e isFile and: [ e extension = 'ston' ] ]) + collect: [ :e | self tryToReadResult: e ] as: OrderedCollection. + + ^ results removeAllSuchThat: [:e | e isNil]. +] + +{ #category : #accessing } +BlBResultsGrapher >> plots [ + + | aCaseLabel data labels boxPlot | + self ensureResults. + self ensureGroups. + + ^ groups collect: [ :someCases | + aCaseLabel := someCases first caseLabel. + data := someCases collect: [ :e | e fpsSamples ]. + labels := someCases collect: [ :e | e shortImageVersion ]. + + boxPlot := RSBoxPlot data: data. + boxPlot xTickLabels: labels. + boxPlot title: aCaseLabel. + boxPlot + ] +] + +{ #category : #'as yet unclassified' } +BlBResultsGrapher >> resultsDirectory: aFileLocator [ + + resultsDirectory := aFileLocator + +] + +{ #category : #'as yet unclassified' } +BlBResultsGrapher >> tryToReadResult: aDiskDirectoryEntry [ + + ^ [ STON fromString: aDiskDirectoryEntry asFileReference contents ] + onErrorDo: [ :e | + ('Rejecting file: ' + , aDiskDirectoryEntry asFileReference fullName) traceCr. + nil ] +] From 8c241a31f4822634ac82cfcf42ea4b613a7a627f Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Tue, 17 Dec 2024 15:28:24 +0100 Subject: [PATCH 17/23] Improving reports --- src/BlocBenchs-Core/BlBCase.class.st | 18 ++++++--- src/BlocBenchs-Core/BlBResult.class.st | 38 ++++++++++++++++++- ...r.class.st => BlBResultsExporter.class.st} | 22 ++++++----- src/BlocBenchs-Core/BlBVersionsMeter.class.st | 2 +- 4 files changed, 63 insertions(+), 17 deletions(-) rename src/BlocBenchs-Core/{BlBResultsGrapher.class.st => BlBResultsExporter.class.st} (71%) diff --git a/src/BlocBenchs-Core/BlBCase.class.st b/src/BlocBenchs-Core/BlBCase.class.st index e662e61..bf49e44 100644 --- a/src/BlocBenchs-Core/BlBCase.class.st +++ b/src/BlocBenchs-Core/BlBCase.class.st @@ -61,11 +61,19 @@ BlBCase class >> runAllWithResultsIn: aDirectory [ aDirectory ensureCreateDirectory. allBenchs := self benchSuite. - ^ allBenchs collectWithIndex: [ :aBench : index| - Stdio stdout << ('Running {1} / {2}...' format: { index. allBenchs size }). result := aBench run. - result serializeResultsInto: aDirectory. - Stdio stdout << ' Ended'; crlf; flush. - result ] + ^ allBenchs collectWithIndex: [ :aBench :index | + Stdio stdout + << ('Running {1} / {2}...' format: { + index. + allBenchs size }); + flush. + result := aBench run. + result serializeResultsInto: aDirectory. + Stdio stdout + << ' Ended'; + crlf; + flush. + result ] ] { #category : #'accessing - defaults' } diff --git a/src/BlocBenchs-Core/BlBResult.class.st b/src/BlocBenchs-Core/BlBResult.class.st index 0d98fc8..e991f7f 100644 --- a/src/BlocBenchs-Core/BlBResult.class.st +++ b/src/BlocBenchs-Core/BlBResult.class.st @@ -68,6 +68,12 @@ BlBResult >> initializeFrom: aBlBCase [ hasError := false. ] +{ #category : #'as yet unclassified' } +BlBResult >> osName [ + + ^ (content at: #osName) second +] + { #category : #'as yet unclassified' } BlBResult >> serializeErrorInto: aDirectory [ @@ -91,6 +97,18 @@ BlBResult >> serializeResultsInto: aDirectory [ ] +{ #category : #'as yet unclassified' } +BlBResult >> shortBlocToploVersion [ + + | versions toploCommit blocCommit | + + versions := (content at: #repositoriesVersions) second. + toploCommit := versions detect: [ :e | e first sameAs: 'toplo' ] ifFound: [ :e | e third ]. + blocCommit := versions detect: [ :e | e first sameAs: 'bloc' ] ifFound: [ :e | e third ]. + + ^ 'T{1}-B{2}' format: { toploCommit. blocCommit } +] + { #category : #accessing } BlBResult >> shortImageVersion [ @@ -100,6 +118,24 @@ BlBResult >> shortImageVersion [ parts := (fullImageVersion allButFirst: 'Pharo-' size) splitOn: [ :e | #( $. $+ ) includes: e ]. - ^ '{1}.{2}.{3} build {6}' format: parts. + ^ '{1}.{2}.{3}-{6}' format: parts. + +] + +{ #category : #'as yet unclassified' } +BlBResult >> shortVMVersion [ + + | matcher | + + matcher := '.*v(\d+\.\d+\.\d+).* Commit\: (\w+) .*' asRegex. + matcher matches: (content at: #vmVersion) second. + + ^ '{1}-{2}' format: { matcher subexpression: 2. matcher subexpression: 3 } + +] + +{ #category : #accessing } +BlBResult >> versionIdentifier [ + ^ '{1}-{2}-{3}-{4}' format: { self shortImageVersion. self shortVMVersion. self shortBlocToploVersion. self osName} ] diff --git a/src/BlocBenchs-Core/BlBResultsGrapher.class.st b/src/BlocBenchs-Core/BlBResultsExporter.class.st similarity index 71% rename from src/BlocBenchs-Core/BlBResultsGrapher.class.st rename to src/BlocBenchs-Core/BlBResultsExporter.class.st index ebcfeb0..611c0cc 100644 --- a/src/BlocBenchs-Core/BlBResultsGrapher.class.st +++ b/src/BlocBenchs-Core/BlBResultsExporter.class.st @@ -1,22 +1,24 @@ Class { - #name : #BlBResultsGrapher, + #name : #BlBResultsExporter, #superclass : #Object, #instVars : [ 'resultsDirectory', 'results', 'groups' ], - #category : #'BlocBenchs-Core-Core' + #category : #'BlocBenchs-Core-Exporter' } { #category : #'as yet unclassified' } -BlBResultsGrapher >> ensureGroups [ - - ^ groups ifNil: [ groups := results groupedBy: [ :e | e caseLabel ] ] +BlBResultsExporter >> ensureGroups [ + + ^ groups ifNil: [ + groups := (results groupedBy: [ :e | e caseLabel ]) collect: [ :e | + e groupedBy: [ :x | x versionIdentifier ] ] ] ] { #category : #'as yet unclassified' } -BlBResultsGrapher >> ensureResults [ +BlBResultsExporter >> ensureResults [ results ifNotNil: [ ^ results ]. @@ -27,7 +29,7 @@ BlBResultsGrapher >> ensureResults [ ] { #category : #accessing } -BlBResultsGrapher >> plots [ +BlBResultsExporter >> plots [ | aCaseLabel data labels boxPlot | self ensureResults. @@ -41,19 +43,19 @@ BlBResultsGrapher >> plots [ boxPlot := RSBoxPlot data: data. boxPlot xTickLabels: labels. boxPlot title: aCaseLabel. - boxPlot + boxPlot build ] ] { #category : #'as yet unclassified' } -BlBResultsGrapher >> resultsDirectory: aFileLocator [ +BlBResultsExporter >> resultsDirectory: aFileLocator [ resultsDirectory := aFileLocator ] { #category : #'as yet unclassified' } -BlBResultsGrapher >> tryToReadResult: aDiskDirectoryEntry [ +BlBResultsExporter >> tryToReadResult: aDiskDirectoryEntry [ ^ [ STON fromString: aDiskDirectoryEntry asFileReference contents ] onErrorDo: [ :e | diff --git a/src/BlocBenchs-Core/BlBVersionsMeter.class.st b/src/BlocBenchs-Core/BlBVersionsMeter.class.st index af6e221..cf29a1d 100644 --- a/src/BlocBenchs-Core/BlBVersionsMeter.class.st +++ b/src/BlocBenchs-Core/BlBVersionsMeter.class.st @@ -59,7 +59,7 @@ BlBVersionsMeter >> repositoriesVersions [ ^ IceRepository registry reject: [ :e | e location isNil ] - thenCollect: [ :e | {e name. e description} ] + thenCollect: [ :e | {e name. e description. e workingCopy referenceCommit id} ] ] { #category : #mettering } From b3aa1221559c56d5bfafe19aeda0a9cf9391c656 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Wed, 18 Dec 2024 11:06:47 +0100 Subject: [PATCH 18/23] Adding machine hostname report --- src/BlocBenchs-Core/BlBResult.class.st | 15 ++++++++------- src/BlocBenchs-Core/BlBVersionsMeter.class.st | 7 ++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/BlocBenchs-Core/BlBResult.class.st b/src/BlocBenchs-Core/BlBResult.class.st index e991f7f..966c237 100644 --- a/src/BlocBenchs-Core/BlBResult.class.st +++ b/src/BlocBenchs-Core/BlBResult.class.st @@ -103,8 +103,8 @@ BlBResult >> shortBlocToploVersion [ | versions toploCommit blocCommit | versions := (content at: #repositoriesVersions) second. - toploCommit := versions detect: [ :e | e first sameAs: 'toplo' ] ifFound: [ :e | e third ]. - blocCommit := versions detect: [ :e | e first sameAs: 'bloc' ] ifFound: [ :e | e third ]. + toploCommit := (versions detect: [ :e | e first sameAs: 'toplo' ]) third first: 8. + blocCommit := (versions detect: [ :e | e first sameAs: 'bloc' ]) third first: 8. ^ 'T{1}-B{2}' format: { toploCommit. blocCommit } ] @@ -112,13 +112,14 @@ BlBResult >> shortBlocToploVersion [ { #category : #accessing } BlBResult >> shortImageVersion [ - | fullImageVersion parts | + | fullImageVersion matcher | fullImageVersion := self imageVersion. - parts := (fullImageVersion allButFirst: 'Pharo-' size) splitOn: [ :e | - #( $. $+ ) includes: e ]. - - ^ '{1}.{2}.{3}-{6}' format: parts. + matcher := '.*-(\d+\.\d+.\d+).*build\.(\d+)\..*' asRegex. + (matcher matches: fullImageVersion) + ifFalse: [ self error: 'Cannot parse imageVersion' ]. + + ^ '{1}-{2}' format: {matcher subexpression: 2. matcher subexpression: 3}. ] diff --git a/src/BlocBenchs-Core/BlBVersionsMeter.class.st b/src/BlocBenchs-Core/BlBVersionsMeter.class.st index cf29a1d..65e216a 100644 --- a/src/BlocBenchs-Core/BlBVersionsMeter.class.st +++ b/src/BlocBenchs-Core/BlBVersionsMeter.class.st @@ -51,7 +51,12 @@ BlBVersionsMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ aBlBResult addField: #osVersion title: 'Operating System Version' - value: self osVersion. + value: self osVersion. + + aBlBResult + addField: #hostname + title: 'Hostname' + value: NetNameResolver localHostName ] { #category : #accessing } From ba5ff997424820734c997115fe0f1db3ac00b949 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 20 Dec 2024 10:13:12 +0100 Subject: [PATCH 19/23] Exporting results --- src/BlocBenchs-Core/BlBResult.class.st | 58 ++++++++++-- src/BlocBenchs-Core/BlBResultsByCase.class.st | 62 +++++++++++++ .../BlBResultsByVersion.class.st | 39 ++++++++ .../BlBResultsExporter.class.st | 82 +++++++++++++---- .../BlBResultsTemplates.class.st | 91 +++++++++++++++++++ 5 files changed, 308 insertions(+), 24 deletions(-) create mode 100644 src/BlocBenchs-Core/BlBResultsByCase.class.st create mode 100644 src/BlocBenchs-Core/BlBResultsByVersion.class.st create mode 100644 src/BlocBenchs-Core/BlBResultsTemplates.class.st diff --git a/src/BlocBenchs-Core/BlBResult.class.st b/src/BlocBenchs-Core/BlBResult.class.st index 966c237..78467b6 100644 --- a/src/BlocBenchs-Core/BlBResult.class.st +++ b/src/BlocBenchs-Core/BlBResult.class.st @@ -30,12 +30,32 @@ BlBResult >> caseLabel [ ^ caseLabel ] +{ #category : #accessing } +BlBResult >> confidenceInterval [ + + | avg deviation | + + avg := self fpsSamples average. + + deviation := MeanConfidenceIntervalPrinter new + gaussianConfidenceFactor: 2; + confidenceIntervalFor: self fpsSamples. + + ^ { avg - deviation. avg + deviation } +] + { #category : #accessing } BlBResult >> content [ ^ content ifNil: [ content := Dictionary new ] ] +{ #category : #accessing } +BlBResult >> date [ + + ^ dateAndTime asDate +] + { #category : #accessing } BlBResult >> error: anError [ @@ -58,6 +78,19 @@ BlBResult >> imageVersion [ ^ (content at: #imageVersion) second. ] +{ #category : #accessing } +BlBResult >> imageVersionGroups [ + + | fullImageVersion matcher | + fullImageVersion := self imageVersion. + + matcher := '.*-(\d+\.\d+.\d+).*build\.(\d+)\..*' asRegex. + (matcher matches: fullImageVersion) + ifFalse: [ self error: 'Cannot parse imageVersion' ]. + + ^ {matcher subexpression: 2. matcher subexpression: 3} +] + { #category : #initialization } BlBResult >> initializeFrom: aBlBCase [ @@ -68,6 +101,22 @@ BlBResult >> initializeFrom: aBlBCase [ hasError := false. ] +{ #category : #testing } +BlBResult >> isBetterThan: aBlBResult [ + + | mine other | + mine := self confidenceInterval. + other := aBlBResult confidenceInterval. + + ^ mine second > other second or: [ mine second between: other first and: other second ] +] + +{ #category : #accessing } +BlBResult >> mainImageVersion [ + + ^ self imageVersionGroups first +] + { #category : #'as yet unclassified' } BlBResult >> osName [ @@ -111,15 +160,8 @@ BlBResult >> shortBlocToploVersion [ { #category : #accessing } BlBResult >> shortImageVersion [ - - | fullImageVersion matcher | - fullImageVersion := self imageVersion. - - matcher := '.*-(\d+\.\d+.\d+).*build\.(\d+)\..*' asRegex. - (matcher matches: fullImageVersion) - ifFalse: [ self error: 'Cannot parse imageVersion' ]. - ^ '{1}-{2}' format: {matcher subexpression: 2. matcher subexpression: 3}. + ^ '{1}-{2}' format: self imageVersionGroups. ] diff --git a/src/BlocBenchs-Core/BlBResultsByCase.class.st b/src/BlocBenchs-Core/BlBResultsByCase.class.st new file mode 100644 index 0000000..4a35fde --- /dev/null +++ b/src/BlocBenchs-Core/BlBResultsByCase.class.st @@ -0,0 +1,62 @@ +Class { + #name : #BlBResultsByCase, + #superclass : #Object, + #instVars : [ + 'caseLabel', + 'versions', + 'allVersionsNames' + ], + #category : #'BlocBenchs-Core-Exporter' +} + +{ #category : #'as yet unclassified' } +BlBResultsByCase >> allVersionsNames [ + + ^ allVersionsNames +] + +{ #category : #'as yet unclassified' } +BlBResultsByCase >> allVersionsNames: aCollection [ + + allVersionsNames := aCollection +] + +{ #category : #'as yet unclassified' } +BlBResultsByCase >> caseLabel [ + + ^ caseLabel +] + +{ #category : #'as yet unclassified' } +BlBResultsByCase >> caseLabel: aString [ + + caseLabel := aString +] + +{ #category : #'as yet unclassified' } +BlBResultsByCase >> caseLabelAsFileName [ + + ^ self caseLabel copyReplaceAll: ' ' with: '_'. +] + +{ #category : #'as yet unclassified' } +BlBResultsByCase >> mustacheDefaultWhenLookupFails [ + + self error +] + +{ #category : #versions } +BlBResultsByCase >> versionTicks [ + + ^ allVersionsNames collect: [ :e | + versions + at: e + ifPresent: [ :x | x versionTicks ] + ifAbsent: { BlBResultsTemplates dashIcon } ] +] + +{ #category : #'instance creation' } +BlBResultsByCase >> versions: aCollection [ + + versions := aCollection +] diff --git a/src/BlocBenchs-Core/BlBResultsByVersion.class.st b/src/BlocBenchs-Core/BlBResultsByVersion.class.st new file mode 100644 index 0000000..ac2d86e --- /dev/null +++ b/src/BlocBenchs-Core/BlBResultsByVersion.class.st @@ -0,0 +1,39 @@ +Class { + #name : #BlBResultsByVersion, + #superclass : #Object, + #instVars : [ + 'version', + 'runs' + ], + #category : #'BlocBenchs-Core-Exporter' +} + +{ #category : #accessing } +BlBResultsByVersion >> runs: aCollection [ + + runs := aCollection +] + +{ #category : #versions } +BlBResultsByVersion >> version: aString [ + + version := aString +] + +{ #category : #'as yet unclassified' } +BlBResultsByVersion >> versionTicks [ + + | filtered last | + filtered := runs reject: [ :e | e fpsSamples isEmpty ]. + filtered ifEmpty: [ ^ { BlBResultsTemplates dashIcon } ]. + + last := filtered last. + + ^ filtered collect: [ :e | + last == e + ifTrue: [ BlBResultsTemplates equalsIcon ] + ifFalse: [ + (last isBetterThan: e) + ifTrue: [ BlBResultsTemplates checkIcon ] + ifFalse: [ BlBResultsTemplates crossIcon ] ] ] +] diff --git a/src/BlocBenchs-Core/BlBResultsExporter.class.st b/src/BlocBenchs-Core/BlBResultsExporter.class.st index 611c0cc..4881150 100644 --- a/src/BlocBenchs-Core/BlBResultsExporter.class.st +++ b/src/BlocBenchs-Core/BlBResultsExporter.class.st @@ -4,7 +4,10 @@ Class { #instVars : [ 'resultsDirectory', 'results', - 'groups' + 'outputDirectory', + 'templates', + 'resultsByCase', + 'imageVersions' ], #category : #'BlocBenchs-Core-Exporter' } @@ -12,9 +15,27 @@ Class { { #category : #'as yet unclassified' } BlBResultsExporter >> ensureGroups [ - ^ groups ifNil: [ - groups := (results groupedBy: [ :e | e caseLabel ]) collect: [ :e | - e groupedBy: [ :x | x versionIdentifier ] ] ] + resultsByCase ifNotNil: [ ^ self ]. + + imageVersions := (results collect: [ :e | e mainImageVersion ] as: Set) asOrderedCollection + sorted: [ :a :b | a < b]. + + resultsByCase := (results groupedBy:[ :e | e caseLabel ]) associations + collect: [ :anAssoc | |byVersion versions| + byVersion := anAssoc value groupedBy: [ :aCase | aCase mainImageVersion]. + versions := byVersion collect: [:runs | + BlBResultsByVersion new + version: runs first mainImageVersion; + runs: runs; + yourself + ]. + + BlBResultsByCase new + caseLabel: anAssoc key; + allVersionsNames: imageVersions; + versions: versions; + yourself + ] ] { #category : #'as yet unclassified' } @@ -29,22 +50,51 @@ BlBResultsExporter >> ensureResults [ ] { #category : #accessing } -BlBResultsExporter >> plots [ - - | aCaseLabel data labels boxPlot | +BlBResultsExporter >> exportResults [ + self ensureResults. self ensureGroups. - ^ groups collect: [ :someCases | - aCaseLabel := someCases first caseLabel. - data := someCases collect: [ :e | e fpsSamples ]. - labels := someCases collect: [ :e | e shortImageVersion ]. + outputDirectory ensureCreateDirectory. + + self generateIndex +] + +{ #category : #'as yet unclassified' } +BlBResultsExporter >> generateFile: aFileReference fromTemplate: templateName withTitle: title andValues: values [ + + aFileReference writeStreamDo: [ :aStream | + aStream truncate. + (ZnNewLineWriterStream on: aStream) + nextPutAll: + ((templates perform: templateName) asMustacheTemplate + value: (values copyWith: (#pageTitle -> title)) + partials: templates partials) ] +] + +{ #category : #'as yet unclassified' } +BlBResultsExporter >> generateIndex [ + + self + generateFile: outputDirectory / 'index.html' + fromTemplate: #index + withTitle: 'Bloc / Toplo Benchmarks Results' + andValues: {#benchs -> resultsByCase. #imageVersions -> imageVersions } asDictionary +] + +{ #category : #accessing } +BlBResultsExporter >> initialize [ + + super initialize. + + outputDirectory := FileLocator imageDirectory / 'reports'. + templates := BlBResultsTemplates new. +] + +{ #category : #accessing } +BlBResultsExporter >> outputDirectory: aDirectory [ - boxPlot := RSBoxPlot data: data. - boxPlot xTickLabels: labels. - boxPlot title: aCaseLabel. - boxPlot build - ] + outputDirectory := aDirectory ] { #category : #'as yet unclassified' } diff --git a/src/BlocBenchs-Core/BlBResultsTemplates.class.st b/src/BlocBenchs-Core/BlBResultsTemplates.class.st new file mode 100644 index 0000000..bc5ccd5 --- /dev/null +++ b/src/BlocBenchs-Core/BlBResultsTemplates.class.st @@ -0,0 +1,91 @@ +Class { + #name : #BlBResultsTemplates, + #superclass : #Object, + #category : #'BlocBenchs-Core-Exporter' +} + +{ #category : #'as yet unclassified' } +BlBResultsTemplates class >> checkIcon [ + + ^ ' + ' +] + +{ #category : #'as yet unclassified' } +BlBResultsTemplates class >> crossIcon [ + + ^ ' +' +] + +{ #category : #'as yet unclassified' } +BlBResultsTemplates class >> dashIcon [ + + ^ ' +' +] + +{ #category : #'as yet unclassified' } +BlBResultsTemplates class >> equalsIcon [ + + ^ ' + ' +] + +{ #category : #accessing } +BlBResultsTemplates >> header [ + + ^ ' + + + + + + {{pageTitle}} + +' +] + +{ #category : #accessing } +BlBResultsTemplates >> index [ + + ^ ' + + + {{> header }} + +

{{pageTitle}}

+ + + + + + {{#imageVersions}} + + {{/imageVersions}} + + + + {{#benchs}} + + + {{#versionTicks}} + + {{/versionTicks}} + + {{/benchs}} + +
Bench Label{{.}}
{{caseLabel}}{{#.}} + {{{.}}} + {{/.}} +
+ + +' +] + +{ #category : #'as yet unclassified' } +BlBResultsTemplates >> partials [ + + ^ { 'header' -> self header } asDictionary +] From 6afb025effe0dc333b0fe292b726bc563ac8ebd9 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Fri, 20 Dec 2024 10:15:09 +0100 Subject: [PATCH 20/23] Adding scripts --- scripts/runAllBenchs.sh | 10 ++++++++ scripts/runBenchmarksInPharo.sh | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 scripts/runAllBenchs.sh create mode 100755 scripts/runBenchmarksInPharo.sh diff --git a/scripts/runAllBenchs.sh b/scripts/runAllBenchs.sh new file mode 100755 index 0000000..9cae417 --- /dev/null +++ b/scripts/runAllBenchs.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -x +set -e + +SCRIPT_DIR=$(realpath "$(dirname ${BASH_SOURCE[0]})") + +PHARO_VERSION=130 VERSION_TO_LOAD=dev ${SCRIPT_DIR}/runBenchmarksInPharo.sh +PHARO_VERSION=120 VERSION_TO_LOAD=dev ${SCRIPT_DIR}/runBenchmarksInPharo.sh +PHARO_VERSION=110 VERSION_TO_LOAD=dev ${SCRIPT_DIR}/runBenchmarksInPharo.sh \ No newline at end of file diff --git a/scripts/runBenchmarksInPharo.sh b/scripts/runBenchmarksInPharo.sh new file mode 100755 index 0000000..be397ab --- /dev/null +++ b/scripts/runBenchmarksInPharo.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +set -x +set -e + +ROOT_DIR=$(pwd) +: "${PHARO_VERSION:=130}" +: "${VERSION_TO_LOAD:=dev}" +: "${DATE:=$(date +%Y-%m-%d)}" + +mkdir -p benchmarks/$PHARO_VERSION/$DATE/image + +pushd benchmarks/$PHARO_VERSION/$DATE +pushd image + +wget -O - get.pharo.org/64/$PHARO_VERSION+vm | bash + +./pharo Pharo.image eval --save \ + "Metacello new \ + baseline: 'BlocBenchs'; \ + repository: 'tonel://$ROOT_DIR/src'; \ + load" + +# We load the requested version of the packages +./pharo Pharo.image eval --save \ +"{ \ + 'alexandrie'. \ + 'bloc'. \ + 'album'. \ + 'toplo'. \ + 'spec-toplo'. \ +} do: [ :repoName | \ + (IceRepository registry \ + select: [ :each | each name asLowercase = repoName ]) \ + do:[ :each | \ + (each branchNamed: '$VERSION_TO_LOAD') checkout. \ + each fetch; pull ] ] \ + displayingProgress: [ :each | each ]. \ +" + +./pharo-ui Pharo.image eval "BlBCase runAllWithResultsIn: FileLocator imageDirectory / '..' / 'results'. Smalltalk snapshot:false andQuit: true." + +popd +rm -rf image +popd \ No newline at end of file From 7d19271ccd2c1e6c944774a42cb35bccfc569a4d Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Thu, 9 Jan 2025 10:54:25 +0100 Subject: [PATCH 21/23] Improving the export of results --- .../BlBResultsExporter.class.st | 3 +- .../BlBResultsTemplates.class.st | 62 ++++++------------- 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/src/BlocBenchs-Core/BlBResultsExporter.class.st b/src/BlocBenchs-Core/BlBResultsExporter.class.st index 4881150..eab8b2a 100644 --- a/src/BlocBenchs-Core/BlBResultsExporter.class.st +++ b/src/BlocBenchs-Core/BlBResultsExporter.class.st @@ -55,7 +55,8 @@ BlBResultsExporter >> exportResults [ self ensureResults. self ensureGroups. - outputDirectory ensureCreateDirectory. + outputDirectory ensureDeleteAll. + templates copyAllResourcesTo: outputDirectory. self generateIndex ] diff --git a/src/BlocBenchs-Core/BlBResultsTemplates.class.st b/src/BlocBenchs-Core/BlBResultsTemplates.class.st index bc5ccd5..33e49f8 100644 --- a/src/BlocBenchs-Core/BlBResultsTemplates.class.st +++ b/src/BlocBenchs-Core/BlBResultsTemplates.class.st @@ -1,6 +1,9 @@ Class { #name : #BlBResultsTemplates, #superclass : #Object, + #instVars : [ + 'templatesDirectory' + ], #category : #'BlocBenchs-Core-Exporter' } @@ -32,56 +35,31 @@ BlBResultsTemplates class >> equalsIcon [ ' ] +{ #category : #copying } +BlBResultsTemplates >> copyAllResourcesTo: aDirectory [ + + (templatesDirectory / 'resources') copyAllTo: aDirectory +] + { #category : #accessing } BlBResultsTemplates >> header [ - ^ ' - - - - - - {{pageTitle}} - -' + ^ (templatesDirectory / 'header.html') contents ] { #category : #accessing } BlBResultsTemplates >> index [ - ^ ' - - - {{> header }} - -

{{pageTitle}}

- - - - - - {{#imageVersions}} - - {{/imageVersions}} - - - - {{#benchs}} - - - {{#versionTicks}} - - {{/versionTicks}} - - {{/benchs}} - -
Bench Label{{.}}
{{caseLabel}}{{#.}} - {{{.}}} - {{/.}} -
- - -' + ^ (templatesDirectory / 'index.html') contents +] + +{ #category : #initialization } +BlBResultsTemplates >> initialize [ + + super initialize. + + templatesDirectory := (IceRepository registry detect: [ :e | + e name = 'BlocBenchs' ]) location / 'templates'. ] { #category : #'as yet unclassified' } From 118369b5ea891259336c3614637fd5056ca865ef Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Thu, 9 Jan 2025 10:54:48 +0100 Subject: [PATCH 22/23] Add benchmark for using composition layers in OverlayAnimation --- .../BlBOverlayAnimationCase.class.st | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/BlocBenchs-Benchs/BlBOverlayAnimationCase.class.st diff --git a/src/BlocBenchs-Benchs/BlBOverlayAnimationCase.class.st b/src/BlocBenchs-Benchs/BlBOverlayAnimationCase.class.st new file mode 100644 index 0000000..8263a51 --- /dev/null +++ b/src/BlocBenchs-Benchs/BlBOverlayAnimationCase.class.st @@ -0,0 +1,105 @@ +Class { + #name : #BlBOverlayAnimationCase, + #superclass : #BlBBlocCase, + #instVars : [ + 'useCompositionLayer' + ], + #category : #'BlocBenchs-Benchs-Bloc' +} + +{ #category : #benchmarking } +BlBOverlayAnimationCase class >> benchMatrix [ + + ^ super benchMatrix + forSelector: #useCompositionLayer + addOptions: #( true false ) +] + +{ #category : #'instance creation' } +BlBOverlayAnimationCase >> createChildElement [ + + | element | + element := BlElement new + background: Color random; + height: 50; + width: 50; + yourself. + + element layout: (BlGridLayout new columnCount: 10). + element layout cellSpacing: 0. + + element addChildren: ((1 to: 100) collect: [ :i | + BlElement new + background: Color random; + height: 5; + width: 5; + yourself ]). + + ^ element + +] + +{ #category : #accessing } +BlBOverlayAnimationCase >> defaultLabel [ + + ^ '{1} withCompositionLayer: {2}' format: { + super defaultLabel. + useCompositionLayer } +] + +{ #category : #'instance creation' } +BlBOverlayAnimationCase >> newElement [ + + | container transparent spinner | + container := BlElement new. + container layout: (BlGridLayout new columnCount: 16). + container layout cellSpacing: 3. + container constraintsDo: [ :c | + c vertical matchParent. + c horizontal matchParent ]. + + 300 timesRepeat: [ + container addChild: (self createChildElement) ]. + + spinner := BlElement new. + spinner constraintsDo: [ :c | + c frame vertical alignCenter. + c frame horizontal alignCenter ]. + spinner height: 50. + spinner width: 50. + spinner background: Color blue. + + spinner addAnimation: ((BlTransformAnimation rotate: 180) + duration: 0.5 seconds; + easing: BlLinearInterpolator new; + target: spinner; + beInfinite; + yourself ). + + transparent := BlElement new. + transparent layout: BlFrameLayout new. + transparent background: (Color gray alpha: 0.5). + transparent constraintsDo: [ :c | + c vertical matchParent. + c horizontal matchParent ]. + transparent addChild: spinner. + + useCompositionLayer ifTrue: [ + container beInSingleCompositionLayer. + transparent beInSingleCompositionLayer ]. + + ^ BlElement new + constraintsDo: [ :c | + c vertical matchParent. + c horizontal matchParent ]; + addChild: container; + addChild: transparent; + yourself + +] + +{ #category : #accessing } +BlBOverlayAnimationCase >> useCompositionLayer: aValue [ + + useCompositionLayer := aValue +] From 6b1abd18211e7ae7cf2faa33a7cc7940ce5ea4b0 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Wed, 15 Jan 2025 14:02:04 +0100 Subject: [PATCH 23/23] Ensuring to stop the meters --- .../BlBAbstractBenchRunner.class.st | 3 ++- .../BlBBlocBenchRunner.class.st | 2 ++ .../BlBBlocRenderingMeter.class.st | 16 ++++++++++++-- .../BlBFFICounterMeter.class.st | 10 +++++++-- src/BlocBenchs-Core/BlBFFILogger.class.st | 10 +++++++-- src/BlocBenchs-Core/BlBMeter.class.st | 4 ++++ .../BlBRawBenchRunner.class.st | 2 ++ .../BlBSystemProfilerMeter.class.st | 21 +++++++++++++++++-- 8 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st b/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st index a61c069..7f274cb 100644 --- a/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st +++ b/src/BlocBenchs-Core/BlBAbstractBenchRunner.class.st @@ -17,7 +17,8 @@ BlBAbstractBenchRunner >> addMeter: aBlBMeter [ { #category : #'as yet unclassified' } BlBAbstractBenchRunner >> cleanUpAfterCase: aBlBCase [ - ^ self subclassResponsibility + + self meters reverse do: [:e | e ensureStop]. ] { #category : #running } diff --git a/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st b/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st index f74f12d..cb18c9c 100644 --- a/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st +++ b/src/BlocBenchs-Core/BlBBlocBenchRunner.class.st @@ -10,6 +10,8 @@ Class { { #category : #running } BlBBlocBenchRunner >> cleanUpAfterCase: aBlBCase [ + super cleanUpAfterCase: aBlBCase. + space ifNil: [ ^ self ]. space close. diff --git a/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st b/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st index 117fd62..f1a69dc 100644 --- a/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st +++ b/src/BlocBenchs-Core/BlBBlocRenderingMeter.class.st @@ -1,9 +1,20 @@ Class { #name : #BlBBlocRenderingMeter, #superclass : #BlBMeter, + #instVars : [ + 'spaceStatistics' + ], #category : #'BlocBenchs-Core-Core' } +{ #category : #mettering } +BlBBlocRenderingMeter >> ensureStop [ + + spaceStatistics ifNil: [ ^ self ]. + spaceStatistics spaceClosed. + spaceStatistics := nil +] + { #category : #reporting } BlBBlocRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ @@ -45,11 +56,12 @@ BlBBlocRenderingMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ { #category : #mettering } BlBBlocRenderingMeter >> startMetering: aBlBBlocBenchRunner [ - aBlBBlocBenchRunner space enableStatistics + aBlBBlocBenchRunner space enableStatistics. + spaceStatistics := aBlBBlocBenchRunner space spaceStatistics. ] { #category : #mettering } BlBBlocRenderingMeter >> stopMetering: aBlBBlocBenchRunner [ - + self ensureStop ] diff --git a/src/BlocBenchs-Core/BlBFFICounterMeter.class.st b/src/BlocBenchs-Core/BlBFFICounterMeter.class.st index 041ae9f..39780b3 100644 --- a/src/BlocBenchs-Core/BlBFFICounterMeter.class.st +++ b/src/BlocBenchs-Core/BlBFFICounterMeter.class.st @@ -7,6 +7,13 @@ Class { #category : #'BlocBenchs-Core-Core' } +{ #category : #mettering } +BlBFFICounterMeter >> ensureStop [ + + TFLSignal uninstall. + TFLFunctionCounter stop; resetInstance. +] + { #category : #reporting } BlBFFICounterMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ @@ -49,6 +56,5 @@ BlBFFICounterMeter >> stopMetering: aBlBBenchRunner [ functionNamesAndCounts := functionNamesAndCounts collect: [ :value | (value / frameCount) asFloat ]. - TFLSignal uninstall. - TFLFunctionCounter stop; resetInstance. + self ensureStop ] diff --git a/src/BlocBenchs-Core/BlBFFILogger.class.st b/src/BlocBenchs-Core/BlBFFILogger.class.st index 6821793..9901dac 100644 --- a/src/BlocBenchs-Core/BlBFFILogger.class.st +++ b/src/BlocBenchs-Core/BlBFFILogger.class.st @@ -7,6 +7,13 @@ Class { #category : #'BlocBenchs-Core-Core' } +{ #category : #mettering } +BlBFFILogger >> ensureStop [ + + TFLSignal uninstall. + TFLCallLogger stop; resetInstance. +] + { #category : #reporting } BlBFFILogger >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ @@ -35,6 +42,5 @@ BlBFFILogger >> stopMetering: aBlBBlocBenchRunner [ loggerCopy := TFLCallLogger instance copy. - TFLSignal uninstall. - TFLCallLogger stop; resetInstance. + self ensureStop ] diff --git a/src/BlocBenchs-Core/BlBMeter.class.st b/src/BlocBenchs-Core/BlBMeter.class.st index f7c9ea7..97e8cca 100644 --- a/src/BlocBenchs-Core/BlBMeter.class.st +++ b/src/BlocBenchs-Core/BlBMeter.class.st @@ -4,6 +4,10 @@ Class { #category : #'BlocBenchs-Core-Core' } +{ #category : #'as yet unclassified' } +BlBMeter >> ensureStop [ +] + { #category : #reporting } BlBMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ diff --git a/src/BlocBenchs-Core/BlBRawBenchRunner.class.st b/src/BlocBenchs-Core/BlBRawBenchRunner.class.st index ebb8ce6..8b4eee9 100644 --- a/src/BlocBenchs-Core/BlBRawBenchRunner.class.st +++ b/src/BlocBenchs-Core/BlBRawBenchRunner.class.st @@ -22,6 +22,8 @@ Class { { #category : #running } BlBRawBenchRunner >> cleanUpAfterCase: aBlBRawCase [ + super cleanUpAfterCase: aBlBRawCase. + steppingProcess ifNotNil: [ steppingProcess terminate. steppingProcess := nil ]. diff --git a/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st b/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st index 1d9bce7..f6f2059 100644 --- a/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st +++ b/src/BlocBenchs-Core/BlBSystemProfilerMeter.class.st @@ -2,11 +2,28 @@ Class { #name : #BlBSystemProfilerMeter, #superclass : #BlBMeter, #instVars : [ - 'profiler' + 'profiler', + 'alreadyStopped' ], #category : #'BlocBenchs-Core-Core' } +{ #category : #mettering } +BlBSystemProfilerMeter >> ensureStop [ + + alreadyStopped ifTrue: [ ^ self ]. + + profiler stopProfiling. + alreadyStopped := true +] + +{ #category : #mettering } +BlBSystemProfilerMeter >> initialize [ + + super initialize. + alreadyStopped := false +] + { #category : #reporting } BlBSystemProfilerMeter >> reportResultsFrom: aBlBBlocBenchRunner in: aBlBResult [ @@ -52,5 +69,5 @@ BlBSystemProfilerMeter >> startMetering: aBlBBlocBenchRunner [ { #category : #mettering } BlBSystemProfilerMeter >> stopMetering: aBlBBlocBenchRunner [ - profiler stopProfiling + self ensureStop ]