]>
Commit | Line | Data |
---|---|---|
7b363ab6 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: tests/benchmarks/image.cpp | |
3 | // Purpose: wxImage benchmarks | |
4 | // Author: Vadim Zeitlin | |
5 | // Created: 2013-06-30 | |
6 | // Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org> | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #include "wx/image.h" | |
11 | ||
12 | #include "bench.h" | |
13 | ||
14 | BENCHMARK_FUNC(LoadBMP) | |
15 | { | |
16 | wxImage image; | |
17 | return image.LoadFile("horse.bmp"); | |
18 | } | |
19 | ||
20 | BENCHMARK_FUNC(LoadJPEG) | |
21 | { | |
22 | static bool s_handlerAdded = false; | |
23 | if ( !s_handlerAdded ) | |
24 | { | |
25 | s_handlerAdded = true; | |
26 | wxImage::AddHandler(new wxJPEGHandler); | |
27 | } | |
28 | ||
29 | wxImage image; | |
30 | return image.LoadFile("horse.jpg"); | |
31 | } | |
32 | ||
33 | BENCHMARK_FUNC(LoadPNG) | |
34 | { | |
35 | static bool s_handlerAdded = false; | |
36 | if ( !s_handlerAdded ) | |
37 | { | |
38 | s_handlerAdded = true; | |
39 | wxImage::AddHandler(new wxPNGHandler); | |
40 | } | |
41 | ||
42 | wxImage image; | |
43 | return image.LoadFile("horse.png"); | |
44 | } | |
45 | ||
46 | BENCHMARK_FUNC(LoadTIFF) | |
47 | { | |
48 | static bool s_handlerAdded = false; | |
49 | if ( !s_handlerAdded ) | |
50 | { | |
51 | s_handlerAdded = true; | |
52 | wxImage::AddHandler(new wxTIFFHandler); | |
53 | } | |
54 | ||
55 | wxImage image; | |
56 | return image.LoadFile("horse.tif"); | |
57 | } | |
544ab85e VZ |
58 | |
59 | static const wxImage& GetTestImage() | |
60 | { | |
61 | static wxImage s_image; | |
62 | static bool s_triedToLoad = false; | |
63 | if ( !s_triedToLoad ) | |
64 | { | |
65 | s_triedToLoad = true; | |
66 | s_image.LoadFile("horse.bmp"); | |
67 | } | |
68 | ||
69 | return s_image; | |
70 | } | |
71 | ||
72 | BENCHMARK_FUNC(EnlargeNormal) | |
73 | { | |
74 | return GetTestImage().Scale(300, 300, wxIMAGE_QUALITY_NORMAL).IsOk(); | |
75 | } | |
76 | ||
77 | BENCHMARK_FUNC(EnlargeHighQuality) | |
78 | { | |
79 | return GetTestImage().Scale(300, 300, wxIMAGE_QUALITY_HIGH).IsOk(); | |
80 | } | |
81 | ||
82 | BENCHMARK_FUNC(ShrinkNormal) | |
83 | { | |
84 | return GetTestImage().Scale(50, 50, wxIMAGE_QUALITY_NORMAL).IsOk(); | |
85 | } | |
86 | ||
87 | BENCHMARK_FUNC(ShrinkHighQuality) | |
88 | { | |
89 | return GetTestImage().Scale(50, 50, wxIMAGE_QUALITY_HIGH).IsOk(); | |
90 | } |