Skip to content

Commit 3cd6cf7

Browse files
committed
move performance tests code to modules/<module_name>/perf/
1 parent 31c1978 commit 3cd6cf7

File tree

2 files changed

+42
-81
lines changed

2 files changed

+42
-81
lines changed

modules/cudawarping/perf/perf_warping.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,48 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, Resize,
180180
}
181181
}
182182

183+
//////////////////////////////////////////////////////////////////////
184+
// ResizeLanczos
185+
186+
PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ResizeLanczos,
187+
Combine(CUDA_TYPICAL_MAT_SIZES,
188+
Values(CV_8U, CV_32F),
189+
CUDA_CHANNELS_1_3_4,
190+
Values(Interpolation(cv::INTER_LANCZOS4)),
191+
Values(0.5, 1.5, 2.0)))
192+
{
193+
declare.time(20.0);
194+
195+
const cv::Size size = GET_PARAM(0);
196+
const int depth = GET_PARAM(1);
197+
const int channels = GET_PARAM(2);
198+
const int interpolation = GET_PARAM(3);
199+
const double f = GET_PARAM(4);
200+
201+
const int type = CV_MAKE_TYPE(depth, channels);
202+
203+
cv::Mat src(size, type);
204+
declare.in(src, WARMUP_RNG);
205+
206+
if (PERF_RUN_CUDA())
207+
{
208+
const cv::cuda::GpuMat d_src(src);
209+
cv::cuda::GpuMat dst;
210+
211+
TEST_CYCLE() cv::cuda::resize(d_src, dst, cv::Size(), f, f, interpolation);
212+
213+
CUDA_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
214+
}
215+
else
216+
{
217+
cv::Mat dst;
218+
219+
TEST_CYCLE() cv::resize(src, dst, cv::Size(), f, f, interpolation);
220+
221+
CPU_SANITY_CHECK(dst);
222+
}
223+
}
224+
183225
//////////////////////////////////////////////////////////////////////
184226
// ResizeArea
185227

modules/cudawarping/test/test_lanczos.cpp

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -151,86 +151,5 @@ INSTANTIATE_TEST_CASE_P(CUDA_Warping, ResizeLanczosSameAsHost, testing::Combine(
151151
testing::Values(0.3, 0.5, 1.5, 2.0),
152152
WHOLE_SUBMAT));
153153

154-
/////////////////
155-
// Performance Test
156-
157-
PARAM_TEST_CASE(ResizeLanczosPerformance, cv::cuda::DeviceInfo, cv::Size, MatType, double)
158-
{
159-
cv::cuda::DeviceInfo devInfo;
160-
cv::Size size;
161-
double coeff;
162-
int type;
163-
164-
virtual void SetUp()
165-
{
166-
devInfo = GET_PARAM(0);
167-
size = GET_PARAM(1);
168-
type = GET_PARAM(2);
169-
coeff = GET_PARAM(3);
170-
171-
cv::cuda::setDevice(devInfo.deviceID());
172-
}
173-
};
174-
175-
CUDA_TEST_P(ResizeLanczosPerformance, Performance)
176-
{
177-
cv::Mat src = randomMat(size, type);
178-
cv::Size dsize(cv::saturate_cast<int>(src.cols * coeff), cv::saturate_cast<int>(src.rows * coeff));
179-
180-
// Warm up
181-
{
182-
cv::cuda::GpuMat gpuSrc, gpuDst;
183-
gpuSrc.upload(src);
184-
gpuDst.create(dsize, type);
185-
cv::cuda::resize(gpuSrc, gpuDst, cv::Size(), coeff, coeff, cv::INTER_LANCZOS4);
186-
cv::Mat dummy;
187-
gpuDst.download(dummy); // Synchronize
188-
}
189-
190-
// GPU performance
191-
const int iterations = 100;
192-
cv::TickMeter tm_gpu;
193-
cv::cuda::GpuMat gpuSrc, gpuDst;
194-
gpuSrc.upload(src);
195-
gpuDst.create(dsize, type);
196-
197-
tm_gpu.start();
198-
for (int i = 0; i < iterations; ++i)
199-
{
200-
cv::cuda::resize(gpuSrc, gpuDst, cv::Size(), coeff, coeff, cv::INTER_LANCZOS4);
201-
}
202-
cv::Mat dummy;
203-
gpuDst.download(dummy); // Synchronize
204-
tm_gpu.stop();
205-
206-
// CPU performance
207-
cv::TickMeter tm_cpu;
208-
cv::Mat dst_cpu;
209-
210-
tm_cpu.start();
211-
for (int i = 0; i < iterations; ++i)
212-
{
213-
cv::resize(src, dst_cpu, cv::Size(), coeff, coeff, cv::INTER_LANCZOS4);
214-
}
215-
tm_cpu.stop();
216-
217-
double gpu_time = tm_gpu.getTimeMilli() / iterations;
218-
double cpu_time = tm_cpu.getTimeMilli() / iterations;
219-
double speedup = cpu_time / gpu_time;
220-
221-
std::cout << "Size: " << size << " -> " << dsize
222-
<< ", Type: " << type
223-
<< ", Coeff: " << coeff << std::endl;
224-
std::cout << " CPU: " << cpu_time << " ms" << std::endl;
225-
std::cout << " GPU: " << gpu_time << " ms" << std::endl;
226-
std::cout << " Speedup: " << speedup << "x" << std::endl;
227-
}
228-
229-
INSTANTIATE_TEST_CASE_P(CUDA_Warping, ResizeLanczosPerformance, testing::Combine(
230-
testing::Values(cv::cuda::DeviceInfo()),
231-
testing::Values(cv::Size(512, 512), cv::Size(1024, 1024), cv::Size(2048, 2048)),
232-
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_32FC1), MatType(CV_32FC3)),
233-
testing::Values(0.5, 1.5, 2.0)));
234-
235154
}} // namespace
236155
#endif // HAVE_CUDA

0 commit comments

Comments
 (0)