Skip to content

Commit

Permalink
Reduce clock syscalls (#4303)
Browse files Browse the repository at this point in the history
Gate the sample of the clock by the tessedit_timing_debug flag,
which is the only time it gets used anyway.

This eliminates unnecessary clock_gettime() system calls.
  • Loading branch information
heshpdx authored Aug 23, 2024
1 parent 215b023 commit 3b9d119
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ccmain/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,10 @@ void Tesseract::classify_word_and_language(int pass_n, PAGE_RES_IT *pr_it, WordD
PointerVector<WERD_RES> best_words;
// Points to the best result. May be word or in lang_words.
const WERD_RES *word = word_data->word;
clock_t start_t = clock();
clock_t start_t = 0;
if (tessedit_timing_debug) {
start_t = clock();
}
const bool debug = classify_debug_level > 0 || multilang_debug_level > 0;
if (debug) {
tprintf("%s word with lang %s at:", word->done ? "Already done" : "Processing",
Expand Down Expand Up @@ -1364,8 +1367,8 @@ void Tesseract::classify_word_and_language(int pass_n, PAGE_RES_IT *pr_it, WordD
} else {
tprintf("no best words!!\n");
}
clock_t ocr_t = clock();
if (tessedit_timing_debug) {
clock_t ocr_t = clock();
tprintf("%s (ocr took %.2f sec)\n", word_data->word->best_choice->unichar_string().c_str(),
static_cast<double>(ocr_t - start_t) / CLOCKS_PER_SEC);
}
Expand Down

0 comments on commit 3b9d119

Please sign in to comment.