summaryrefslogtreecommitdiff
path: root/test/uitests/benchmarktest.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-03-07 14:22:56 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2020-03-07 19:23:26 +0100
commitd9d7188ad7b22e8991a9ef685840ac0e88566b39 (patch)
tree23ac163bfb60cce4b9aefb658df5322687db1dc6 /test/uitests/benchmarktest.cc
parentdf71bccf9c4731af9bcca79eee8d95651646bd82 (diff)
Use vector for PixelBuffer memory allocation. Use optimized render routines in some more painter algorithms. Fix capitalization of Canvas::getPixelBuffer method.
Diffstat (limited to 'test/uitests/benchmarktest.cc')
-rw-r--r--test/uitests/benchmarktest.cc34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/uitests/benchmarktest.cc b/test/uitests/benchmarktest.cc
index 33defc6..aaf3946 100644
--- a/test/uitests/benchmarktest.cc
+++ b/test/uitests/benchmarktest.cc
@@ -37,11 +37,16 @@ class TimedCanvas
: public GUI::Canvas
{
public:
- GUI::PixelBufferAlpha& GetPixelBuffer() override
+ GUI::PixelBufferAlpha& getPixelBuffer() override
{
return pixbuf;
}
+ void resize(std::size_t width, std::size_t height)
+ {
+ pixbuf.realloc(width, height);
+ }
+
private:
GUI::PixelBufferAlpha pixbuf{800, 600};
};
@@ -84,6 +89,33 @@ int main()
GUI::Image image_inner_alpha(":benchmarktest_resources/image_inner_alpha.png");
{
+ TimedCanvas canvas;
+ TimedScope timed("Pixelbuffer resize", 100000);
+ painter.setColour(GUI::Colour(1.f, 1.f, 1.f, 1.f));
+ for(int i = 0; i < 100000; ++i)
+ {
+ canvas.resize(i % 1000 + 100, i % 1000 + 100);
+ }
+ }
+
+ {
+ TimedScope timed("Filled rect, no alpha", 100000);
+ for(int i = 0; i < 100000; ++i)
+ {
+ painter.drawRectangle(0, 0, 800, 600);
+ }
+ }
+
+ {
+ TimedScope timed("Filled rect, with alpha", 100000);
+ painter.setColour(GUI::Colour(1.f, 1.f, 1.f, 0.5f));
+ for(int i = 0; i < 100000; ++i)
+ {
+ painter.drawRectangle(0, 0, 800, 600);
+ }
+ }
+
+ {
TimedScope timed("No scale, no alpha", 100000);
for(int i = 0; i < 100000; ++i)
{