From 544ab85e05ac2eb8bfa507bb8f81b87a69b2000c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 1 Jul 2013 14:48:01 +0000 Subject: [PATCH] Add wxImage::Scale() benchmarks. Measure the time taken to rescale the image to a bigger or smaller size using normal or high quality. See #15281. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74320 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/benchmarks/image.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/benchmarks/image.cpp b/tests/benchmarks/image.cpp index 5e2b4cade9..350cd9f9bc 100644 --- a/tests/benchmarks/image.cpp +++ b/tests/benchmarks/image.cpp @@ -55,3 +55,36 @@ BENCHMARK_FUNC(LoadTIFF) wxImage image; return image.LoadFile("horse.tif"); } + +static const wxImage& GetTestImage() +{ + static wxImage s_image; + static bool s_triedToLoad = false; + if ( !s_triedToLoad ) + { + s_triedToLoad = true; + s_image.LoadFile("horse.bmp"); + } + + return s_image; +} + +BENCHMARK_FUNC(EnlargeNormal) +{ + return GetTestImage().Scale(300, 300, wxIMAGE_QUALITY_NORMAL).IsOk(); +} + +BENCHMARK_FUNC(EnlargeHighQuality) +{ + return GetTestImage().Scale(300, 300, wxIMAGE_QUALITY_HIGH).IsOk(); +} + +BENCHMARK_FUNC(ShrinkNormal) +{ + return GetTestImage().Scale(50, 50, wxIMAGE_QUALITY_NORMAL).IsOk(); +} + +BENCHMARK_FUNC(ShrinkHighQuality) +{ + return GetTestImage().Scale(50, 50, wxIMAGE_QUALITY_HIGH).IsOk(); +}