1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
23 #include <core/GP_Context.h>
24 #include <gfx/GP_Gfx.h>
28 static int bench_line(GP_PixelType type
)
30 GP_Context
*img
= GP_ContextAlloc(800, 600, type
);
33 tst_err("Malloc failed");
39 for (i
= 0; i
< 100000; i
++) {
40 GP_Line(img
, 0 + i
% 100, 0 - i
% 100,
41 800 - i
%200, 600 + i
%200, i
% 0xff);
47 static int bench_line_1bpp(void)
49 return bench_line(GP_PIXEL_G1
);
52 static int bench_line_2bpp(void)
54 return bench_line(GP_PIXEL_G2
);
57 static int bench_line_4bpp(void)
59 return bench_line(GP_PIXEL_G4
);
62 static int bench_line_8bpp(void)
64 return bench_line(GP_PIXEL_G8
);
67 static int bench_line_32bpp(void)
69 return bench_line(GP_PIXEL_RGB888
);
72 static int bench_circle(GP_PixelType type
)
74 GP_Context
*img
= GP_ContextAlloc(800, 600, type
);
77 tst_err("Malloc failed");
83 for (i
= 0; i
< 100000; i
++) {
84 GP_Circle(img
, img
->w
/2, img
->h
/2, i
% 1000, i
%0xff);
90 static int bench_circle_1bpp(void)
92 return bench_circle(GP_PIXEL_G1
);
95 static int bench_circle_2bpp(void)
97 return bench_circle(GP_PIXEL_G2
);
100 static int bench_circle_4bpp(void)
102 return bench_circle(GP_PIXEL_G4
);
105 static int bench_circle_8bpp(void)
107 return bench_circle(GP_PIXEL_G8
);
110 static int bench_circle_32bpp(void)
112 return bench_circle(GP_PIXEL_RGB888
);
115 const struct tst_suite tst_suite
= {
116 .suite_name
= "GFX Benchmark",
118 {.name
= "Line 1BPP", .tst_fn
= bench_line_1bpp
,
120 {.name
= "Line 2BPP", .tst_fn
= bench_line_2bpp
,
122 {.name
= "Line 4BPP", .tst_fn
= bench_line_4bpp
,
124 {.name
= "Line 8BPP", .tst_fn
= bench_line_8bpp
,
126 {.name
= "Line 32BPP", .tst_fn
= bench_line_32bpp
,
129 {.name
= "Circle 1BPP", .tst_fn
= bench_circle_1bpp
,
131 {.name
= "Circle 2BPP", .tst_fn
= bench_circle_2bpp
,
133 {.name
= "Circle 4BPP", .tst_fn
= bench_circle_4bpp
,
135 {.name
= "Circle 8BPP", .tst_fn
= bench_circle_8bpp
,
137 {.name
= "Circle 32BPP", .tst_fn
= bench_circle_32bpp
,