| 2437 | } |
| 2438 | |
| 2439 | static double getLineMasksMorphMicroBench(GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) { |
| 2440 | |
| 2441 | double time = 0; |
| 2442 | #if ON_WINDOWS |
| 2443 | LARGE_INTEGER freq, time_funct_start, time_funct_end; |
| 2444 | QueryPerformanceFrequency(&freq); |
| 2445 | #elif ON_APPLE |
| 2446 | mach_timebase_info_data_t info = {0, 0}; |
| 2447 | mach_timebase_info(&info); |
| 2448 | long long start, stop; |
| 2449 | #else |
| 2450 | timespec time_funct_start, time_funct_end; |
| 2451 | #endif |
| 2452 | |
| 2453 | // input data |
| 2454 | int resolution = 300; |
| 2455 | int wpl = pixGetWpl(input.pix); |
| 2456 | int kThinLineFraction = 20; // tess constant |
| 2457 | int kMinLineLengthFraction = 4; // tess constant |
| 2458 | int max_line_width = resolution / kThinLineFraction; |
| 2459 | int min_line_length = resolution / kMinLineLengthFraction; |
| 2460 | int closing_brick = max_line_width / 3; |
| 2461 | |
| 2462 | // function call |
| 2463 | if (type == DS_DEVICE_OPENCL_DEVICE) { |
| 2464 | #if ON_WINDOWS |
| 2465 | QueryPerformanceCounter(&time_funct_start); |
| 2466 | #elif ON_APPLE |
| 2467 | start = mach_absolute_time(); |
| 2468 | #else |
| 2469 | clock_gettime( CLOCK_MONOTONIC, &time_funct_start ); |
| 2470 | #endif |
| 2471 | OpenclDevice::gpuEnv = *env; |
| 2472 | OpenclDevice::initMorphCLAllocations(wpl, input.height, input.pix); |
| 2473 | Pix *pix_vline = NULL, *pix_hline = NULL, *pix_closed = NULL; |
| 2474 | OpenclDevice::pixGetLinesCL( |
| 2475 | NULL, input.pix, &pix_vline, &pix_hline, &pix_closed, true, |
| 2476 | closing_brick, closing_brick, max_line_width, max_line_width, |
| 2477 | min_line_length, min_line_length); |
| 2478 | |
| 2479 | OpenclDevice::releaseMorphCLBuffers(); |
| 2480 | |
| 2481 | #if ON_WINDOWS |
| 2482 | QueryPerformanceCounter(&time_funct_end); |
| 2483 | time = (time_funct_end.QuadPart-time_funct_start.QuadPart)/(double)(freq.QuadPart); |
| 2484 | #elif ON_APPLE |
| 2485 | stop = mach_absolute_time(); |
| 2486 | time = ((stop - start) * (double)info.numer / info.denom) / 1.0E9; |
| 2487 | #else |
| 2488 | clock_gettime( CLOCK_MONOTONIC, &time_funct_end ); |
| 2489 | 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; |
| 2490 | #endif |
| 2491 | } else { |
| 2492 | #if ON_WINDOWS |
| 2493 | QueryPerformanceCounter(&time_funct_start); |
| 2494 | #elif ON_APPLE |
| 2495 | start = mach_absolute_time(); |
| 2496 | #else |
no test coverage detected