Skip to content

Commit

Permalink
tune the number of iterations and runs
Browse files Browse the repository at this point in the history
Tune the number of iterations and runs per bench. The goal is to lower
the variance of the average performance and to reduce bench time if
doable.

Still have an important variance on the MouseMove bench.

Signed-off-by: Ludovic Desroches <[email protected]>
  • Loading branch information
ldesroches committed Apr 3, 2024
1 parent e306c51 commit 788fee4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ using namespace std;
using namespace egt;
using namespace egt::experimental;

BENCHMARK(ColorFixture, RGBAInterpolation, 10, 100)
BENCHMARK(ColorFixture, RGBAInterpolation, 10, 1000)
{
ColorMap colors({Palette::red, Palette::green});
for (auto x = 0; x < 100; x++)
colors.interp(1.f / x);
}

BENCHMARK(ColorFixture, HSVInterpolation, 10, 100)
BENCHMARK(ColorFixture, HSVInterpolation, 10, 1000)
{
ColorMap colors({Palette::red, Palette::green}, ColorMap::Interpolation::hsv);
for (auto x = 0; x < 100; x++)
colors.interp(1.f / x);
}

BENCHMARK(ColorFixture, HSLInterpolation, 10, 100)
BENCHMARK(ColorFixture, HSLInterpolation, 10, 1000)
{
ColorMap colors({Palette::red, Palette::green}, ColorMap::Interpolation::hsl);
for (auto x = 0; x < 100; x++)
Expand Down Expand Up @@ -114,15 +114,15 @@ class DrawFixture : public ::hayai::Fixture
vector<WidgetMover<Button>> movers;
};

BENCHMARK_F(DrawFixture, MoveAnimate, 10, 500)
BENCHMARK_F(DrawFixture, MoveAnimate, 10, 50)
{
for (auto& mover : movers)
mover.animate();

app.event().draw();
}

BENCHMARK_F(DrawFixture, UpdateButton, 10, 500)
BENCHMARK_F(DrawFixture, UpdateButton, 10, 50)
{
for (auto& mover : movers)
mover.change();
Expand Down Expand Up @@ -153,15 +153,15 @@ class WidgetFixture : public ::hayai::Fixture
CheckBox checkbox{sizer, "CheckBox"};
};

BENCHMARK_F(WidgetFixture, UpdateTextBox, 10, 1000)
BENCHMARK_F(WidgetFixture, UpdateTextBox, 10, 100)
{
text.text("Test String");
app.event().draw();
text.text("Longer test string");
app.event().draw();
}

BENCHMARK_F(WidgetFixture, UpdateCheckBox, 10, 1000)
BENCHMARK_F(WidgetFixture, UpdateCheckBox, 10, 100)
{
checkbox.checked(!checkbox.checked());
app.event().draw();
Expand Down Expand Up @@ -233,7 +233,7 @@ BENCHMARK_F(DrawShapeFixture, DrawLinesAlpha, 10, 1000)
app.event().draw();
}

BENCHMARK_F(DrawShapeFixture, DrawSquares, 10, 1000)
BENCHMARK_F(DrawShapeFixture, DrawSquares, 10, 500)
{
Painter painter{window.screen()->context()};
Color color(uniform_dist_rgb(e1), uniform_dist_rgb(e1), uniform_dist_rgb(e1));
Expand All @@ -249,7 +249,7 @@ BENCHMARK_F(DrawShapeFixture, DrawSquares, 10, 1000)
app.event().draw();
}

BENCHMARK_F(DrawShapeFixture, DrawSquaresAlpha, 10, 1000)
BENCHMARK_F(DrawShapeFixture, DrawSquaresAlpha, 10, 500)
{
Painter painter{window.screen()->context()};
Color color(uniform_dist_rgb(e1), uniform_dist_rgb(e1), uniform_dist_rgb(e1), uniform_dist_rgb(e1));
Expand Down Expand Up @@ -400,7 +400,7 @@ class InputFixture : public ::hayai::Fixture
int y{window.size().height() / 2};
};

BENCHMARK_F(InputFixture, MouseMove, 10, 10000)
BENCHMARK_F(InputFixture, MouseMove, 20, 25000)
{
Event down(EventId::raw_pointer_down, Pointer(DisplayPoint(x, y)));
input.dis(down);
Expand Down

0 comments on commit 788fee4

Please sign in to comment.