Serenity Operating System
at master 54 lines 1.6 kB view raw
1/* 2 * Copyright (c) 2021, Oleg Sikorskiy <olegsik@gmail.com> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <LibTest/TestCase.h> 8 9#include <LibGfx/Bitmap.h> 10#include <LibGfx/Font/FontDatabase.h> 11#include <LibGfx/Painter.h> 12#include <stdio.h> 13 14BENCHMARK_CASE(diagonal_lines) 15{ 16 int const run_count = 50; 17 int const bitmap_size = 2000; 18 19 auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }).release_value_but_fixme_should_propagate_errors(); 20 Gfx::Painter painter(bitmap); 21 22 for (int run = 0; run < run_count; run++) { 23 for (int i = 0; i < bitmap_size; i++) { 24 painter.draw_line({ 0, 0 }, { i, bitmap_size - 1 }, Color::Blue); 25 painter.draw_line({ 0, 0 }, { bitmap_size - 1, i }, Color::Blue); 26 } 27 } 28} 29 30BENCHMARK_CASE(fill) 31{ 32 int const run_count = 1000; 33 int const bitmap_size = 2000; 34 35 auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }).release_value_but_fixme_should_propagate_errors(); 36 Gfx::Painter painter(bitmap); 37 38 for (int run = 0; run < run_count; run++) { 39 painter.fill_rect(bitmap->rect(), Color::Blue); 40 } 41} 42 43BENCHMARK_CASE(fill_with_gradient) 44{ 45 int const run_count = 50; 46 int const bitmap_size = 2000; 47 48 auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }).release_value_but_fixme_should_propagate_errors(); 49 Gfx::Painter painter(bitmap); 50 51 for (int run = 0; run < run_count; run++) { 52 painter.fill_rect_with_gradient(bitmap->rect(), Color::Blue, Color::Red); 53 } 54}