MCPcopy Create free account
hub / github.com/creatale/node-dv / composeRGBPixelMicroBench

Function composeRGBPixelMicroBench

deps/tesseract/opencl/openclwrapper.cpp:2147–2227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2145 *****************************************************************************/
2146
2147static double composeRGBPixelMicroBench(GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) {
2148 double time = 0;
2149#if ON_WINDOWS
2150 LARGE_INTEGER freq, time_funct_start, time_funct_end;
2151 QueryPerformanceFrequency(&freq);
2152#elif ON_APPLE
2153 mach_timebase_info_data_t info = {0, 0};
2154 mach_timebase_info(&info);
2155 long long start, stop;
2156#else
2157 timespec time_funct_start, time_funct_end;
2158#endif
2159 // input data
2160 l_uint32 *tiffdata = (l_uint32 *)input.imageData;// same size and random data; data doesn't change workload
2161
2162 // function call
2163 if (type == DS_DEVICE_OPENCL_DEVICE) {
2164#if ON_WINDOWS
2165 QueryPerformanceCounter(&time_funct_start);
2166#elif ON_APPLE
2167 start = mach_absolute_time();
2168#else
2169 clock_gettime( CLOCK_MONOTONIC, &time_funct_start );
2170#endif
2171
2172 OpenclDevice::gpuEnv = *env;
2173 int wpl = pixGetWpl(input.pix);
2174 OpenclDevice::pixReadFromTiffKernel(tiffdata, input.width, input.height,
2175 wpl, NULL);
2176#if ON_WINDOWS
2177 QueryPerformanceCounter(&time_funct_end);
2178 time = (time_funct_end.QuadPart-time_funct_start.QuadPart)/(double)(freq.QuadPart);
2179#elif ON_APPLE
2180 stop = mach_absolute_time();
2181 time = ((stop - start) * (double)info.numer / info.denom) / 1.0E9;
2182#else
2183 clock_gettime( CLOCK_MONOTONIC, &time_funct_end );
2184 time = (time_funct_end.tv_sec - time_funct_start.tv_sec)*1.0 + (time_funct_end.tv_nsec - time_funct_start.tv_nsec)/1000000000.0;
2185#endif
2186
2187 } else {
2188#if ON_WINDOWS
2189 QueryPerformanceCounter(&time_funct_start);
2190#elif ON_APPLE
2191 start = mach_absolute_time();
2192#else
2193 clock_gettime( CLOCK_MONOTONIC, &time_funct_start );
2194#endif
2195 Pix *pix = pixCreate(input.width, input.height, 32);
2196 l_uint32 *pixData = pixGetData(pix);
2197 int i, j;
2198 int idx = 0;
2199 for (i = 0; i < input.height ; i++) {
2200 for (j = 0; j < input.width; j++) {
2201 l_uint32 tiffword = tiffdata[i * input.width + j];
2202 l_int32 rval = ((tiffword) & 0xff);
2203 l_int32 gval = (((tiffword) >> 8) & 0xff);
2204 l_int32 bval = (((tiffword) >> 16) & 0xff);

Callers 1

evaluateScoreForDeviceFunction · 0.85

Calls 4

pixGetWplFunction · 0.85
pixCreateFunction · 0.85
pixGetDataFunction · 0.85
pixDestroyFunction · 0.85

Tested by

no test coverage detected