Skip to content

Commit d42413d

Browse files
committed
OpenCL: Remove PERF_COUNT framework
It was rarely used, but added a lot of code and an unconditional dependency on openclwrapper.h. Signed-off-by: Stefan Weil <[email protected]>
1 parent ec8f02c commit d42413d

File tree

7 files changed

+33
-213
lines changed

7 files changed

+33
-213
lines changed

src/api/baseapi.cpp

+3-12
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@
7070
#include "mutableiterator.h" // for MutableIterator
7171
#include "normalis.h" // for kBlnBaselineOffset, kBlnXHeight
7272
#include "ocrclass.h" // for ETEXT_DESC
73-
#include "openclwrapper.h" // for PERF_COUNT_END, PERF_COUNT_START, PERF...
73+
#if defined(USE_OPENCL)
74+
#include "openclwrapper.h" // for OpenclDevice
75+
#endif
7476
#include "osdetect.h" // for OSResults, OSBestResult, OrientationId...
7577
#include "pageres.h" // for PAGE_RES_IT, WERD_RES, PAGE_RES, CR_DE...
7678
#include "paragraphs.h" // for DetectParagraphs
@@ -360,7 +362,6 @@ int TessBaseAPI::Init(const char* data, int data_size, const char* language,
360362
const GenericVector<STRING>* vars_vec,
361363
const GenericVector<STRING>* vars_values,
362364
bool set_only_non_debug_params, FileReader reader) {
363-
PERF_COUNT_START("TessBaseAPI::Init")
364365
// Default language is "eng".
365366
if (language == nullptr) language = "eng";
366367
STRING datapath = data_size == 0 ? data : language;
@@ -376,12 +377,10 @@ int TessBaseAPI::Init(const char* data, int data_size, const char* language,
376377
delete tesseract_;
377378
tesseract_ = nullptr;
378379
}
379-
// PERF_COUNT_SUB("delete tesseract_")
380380
#ifdef USE_OPENCL
381381
OpenclDevice od;
382382
od.InitEnv();
383383
#endif
384-
PERF_COUNT_SUB("OD::InitEnv()")
385384
bool reset_classifier = true;
386385
if (tesseract_ == nullptr) {
387386
reset_classifier = false;
@@ -400,7 +399,6 @@ int TessBaseAPI::Init(const char* data, int data_size, const char* language,
400399
}
401400
}
402401

403-
PERF_COUNT_SUB("update tesseract_")
404402
// Update datapath and language requested for the last valid initialization.
405403
if (datapath_ == nullptr)
406404
datapath_ = new STRING(datapath);
@@ -417,14 +415,11 @@ int TessBaseAPI::Init(const char* data, int data_size, const char* language,
417415
last_oem_requested_ = oem;
418416

419417
#ifndef DISABLED_LEGACY_ENGINE
420-
// PERF_COUNT_SUB("update last_oem_requested_")
421418
// For same language and datapath, just reset the adaptive classifier.
422419
if (reset_classifier) {
423420
tesseract_->ResetAdaptiveClassifier();
424-
PERF_COUNT_SUB("tesseract_->ResetAdaptiveClassifier()")
425421
}
426422
#endif // ndef DISABLED_LEGACY_ENGINE
427-
PERF_COUNT_END
428423
return 0;
429424
}
430425

@@ -1106,7 +1101,6 @@ bool TessBaseAPI::ProcessPagesInternal(const char* filename,
11061101
const char* retry_config,
11071102
int timeout_millisec,
11081103
TessResultRenderer* renderer) {
1109-
PERF_COUNT_START("ProcessPages")
11101104
bool stdInput = !strcmp(filename, "stdin") || !strcmp(filename, "-");
11111105
if (stdInput) {
11121106
#ifdef WIN32
@@ -1199,14 +1193,12 @@ bool TessBaseAPI::ProcessPagesInternal(const char* filename,
11991193
if (!r || (renderer && !renderer->EndDocument())) {
12001194
return false;
12011195
}
1202-
PERF_COUNT_END
12031196
return true;
12041197
}
12051198

12061199
bool TessBaseAPI::ProcessPage(Pix* pix, int page_index, const char* filename,
12071200
const char* retry_config, int timeout_millisec,
12081201
TessResultRenderer* renderer) {
1209-
PERF_COUNT_START("ProcessPage")
12101202
SetInputName(filename);
12111203
SetImage(pix);
12121204
bool failed = false;
@@ -1264,7 +1256,6 @@ bool TessBaseAPI::ProcessPage(Pix* pix, int page_index, const char* filename,
12641256
failed = !renderer->AddImage(this);
12651257
}
12661258

1267-
PERF_COUNT_END
12681259
return !failed;
12691260
}
12701261

src/api/tesseractmain.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#include "baseapi.h"
2929
#include "basedir.h"
3030
#include "dict.h"
31-
#include "openclwrapper.h" // for PERF_COUNT_START, ...
31+
#if defined(USE_OPENCL)
32+
#include "openclwrapper.h" // for OpenclDevice
33+
#endif
3234
#include "osdetect.h"
3335
#include "renderer.h"
3436
#include "simddetect.h"
@@ -582,8 +584,6 @@ int main(int argc, char** argv) {
582584
if (image == nullptr && !list_langs && !print_parameters)
583585
return EXIT_SUCCESS;
584586

585-
PERF_COUNT_START("Tesseract:main")
586-
587587
// Call GlobalDawgCache here to create the global DawgCache object before
588588
// the TessBaseAPI object. This fixes the order of destructor calls:
589589
// first TessBaseAPI must be destructed, DawgCache must be the last object.
@@ -721,7 +721,5 @@ int main(int argc, char** argv) {
721721
}
722722
}
723723

724-
PERF_COUNT_END
725-
726724
return EXIT_SUCCESS;
727725
}

src/ccmain/thresholder.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
#include <cstring>
2626

2727
#include "otsuthr.h"
28+
#include "tprintf.h" // for tprintf
2829

29-
#include "openclwrapper.h" // for PERF_COUNT_START, ...
30+
#if defined(USE_OPENCL)
31+
#include "openclwrapper.h" // for OpenclDevice
32+
#endif
3033

3134
namespace tesseract {
3235

@@ -263,7 +266,6 @@ Pix* ImageThresholder::GetPixRectGrey() {
263266
// Otsu thresholds the rectangle, taking the rectangle from *this.
264267
void ImageThresholder::OtsuThresholdRectToPix(Pix* src_pix,
265268
Pix** out_pix) const {
266-
PERF_COUNT_START("OtsuThresholdRectToPix")
267269
int* thresholds;
268270
int* hi_values;
269271

@@ -286,8 +288,6 @@ void ImageThresholder::OtsuThresholdRectToPix(Pix* src_pix,
286288
#endif
287289
delete [] thresholds;
288290
delete [] hi_values;
289-
290-
PERF_COUNT_END
291291
}
292292

293293
/// Threshold the rectangle, taking everything except the src_pix
@@ -299,7 +299,6 @@ void ImageThresholder::ThresholdRectToPix(Pix* src_pix,
299299
const int* thresholds,
300300
const int* hi_values,
301301
Pix** pix) const {
302-
PERF_COUNT_START("ThresholdRectToPix")
303302
*pix = pixCreate(rect_width_, rect_height_, 1);
304303
uint32_t* pixdata = pixGetData(*pix);
305304
int wpl = pixGetWpl(*pix);
@@ -325,8 +324,6 @@ void ImageThresholder::ThresholdRectToPix(Pix* src_pix,
325324
SET_DATA_BIT(pixline, x);
326325
}
327326
}
328-
329-
PERF_COUNT_END
330327
}
331328

332329
} // namespace tesseract.

src/ccstruct/otsuthr.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
#include <cstring>
2323
#include "allheaders.h"
2424
#include "helpers.h"
25-
#include "openclwrapper.h" // for PERF_COUNT_START, ...
25+
#if defined(USE_OPENCL)
26+
#include "openclwrapper.h" // for OpenclDevice
27+
#endif
2628

2729
namespace tesseract {
2830

@@ -40,7 +42,6 @@ int OtsuThreshold(Pix* src_pix, int left, int top, int width, int height,
4042
int num_channels = pixGetDepth(src_pix) / 8;
4143
// Of all channels with no good hi_value, keep the best so we can always
4244
// produce at least one answer.
43-
PERF_COUNT_START("OtsuThreshold")
4445
int best_hi_value = 1;
4546
int best_hi_index = 0;
4647
bool any_good_hivalue = false;
@@ -139,7 +140,6 @@ int OtsuThreshold(Pix* src_pix, int left, int top, int width, int height,
139140
// Use the best of the ones that were not good enough.
140141
(*hi_values)[best_hi_index] = best_hi_value;
141142
}
142-
PERF_COUNT_END
143143
return num_channels;
144144
}
145145

@@ -150,7 +150,6 @@ int OtsuThreshold(Pix* src_pix, int left, int top, int width, int height,
150150
void HistogramRect(Pix* src_pix, int channel,
151151
int left, int top, int width, int height,
152152
int* histogram) {
153-
PERF_COUNT_START("HistogramRect")
154153
int num_channels = pixGetDepth(src_pix) / 8;
155154
channel = ClipToRange(channel, 0, num_channels - 1);
156155
int bottom = top + height;
@@ -164,7 +163,6 @@ void HistogramRect(Pix* src_pix, int channel,
164163
++histogram[pixel];
165164
}
166165
}
167-
PERF_COUNT_END
168166
}
169167

170168
// Computes the Otsu threshold(s) for the given histogram.

0 commit comments

Comments
 (0)