Package: diffpdf Version: 2.1.3-1+b1 Severity: wishlist Tags: patch Dear Maintainer,
* What led up to the situation? Comparison of two testsuitereports lasts more then a minute * What exactly did you do I wrote a patch to minimize the time of comparison * What was the outcome of this action? Now it only takes a few seconds to compare two testsuitereports -- System Information: Debian Release: 8.9 APT prefers oldstable-updates APT policy: (500, 'oldstable-updates'), (500, 'oldstable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.16.0-4-amd64 (SMP w/16 CPU cores) Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages diffpdf depends on: ii libc6 2.19-18+deb8u10 ii libgcc1 1:4.9.2-10 ii libpoppler-qt4-4 0.26.5-2+deb8u1 ii libqtcore4 4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1 ii libqtgui4 4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1 ii libstdc++6 4.9.2-10 diffpdf recommends no packages. diffpdf suggests no packages. -- no debconf information
Index: diffpdf-2.1.3/mainwindow.cpp =================================================================== --- diffpdf-2.1.3.orig/mainwindow.cpp 2017-10-04 15:30:55.579372153 +0200 +++ diffpdf-2.1.3/mainwindow.cpp 2017-10-04 15:46:18.675949547 +0200 @@ -44,6 +44,7 @@ #include <QSettings> #include <QSpinBox> #include <QSplitter> +#include <omp.h> MainWindow::MainWindow(const Debug debug, @@ -1415,40 +1416,62 @@ QList<int> pages1 = getPageList(1, pdf1); QList<int> pages2 = getPageList(2, pdf2); int total = qMin(pages1.count(), pages2.count()); - int number = 0; + int index = 0; - while (!pages1.isEmpty() && !pages2.isEmpty()) { - int p1 = pages1.takeFirst(); - PdfPage page1(pdf1->page(p1)); - if (!page1) { - writeError(tr("Failed to read page %1 from '%2'.") - .arg(p1 + 1).arg(filename1)); - continue; - } - int p2 = pages2.takeFirst(); - PdfPage page2(pdf2->page(p2)); - if (!page2) { - writeError(tr("Failed to read page %1 from '%2'.") - .arg(p2 + 1).arg(filename2)); - continue; - } - writeLine(tr("Comparing: %1 vs. %2.").arg(p1 + 1).arg(p2 + 1)); - QApplication::processEvents(); - if (cancel) { - writeError(tr("Cancelled.")); - break; - } - Difference difference = getTheDifference(page1, page2); - if (difference != NoDifference) { - QVariant v; - v.setValue(PagePair(p1, p2, difference == VisualDifference)); - viewDiffComboBox->addItem(tr("%1 vs. %2 %3 %4") - .arg(p1 + 1).arg(p2 + 1).arg(QChar(0x2022)) - .arg(++index), v); - } - statusLabel->setText(tr("Comparing %1/%2").arg(++number) - .arg(total)); + int number = 0; + int processed = 0; + + Difference difference[total]; + +#pragma omp parallel for schedule(dynamic) + for (number = 0; number < total; number++) { + + int p1 = pages1[number]; + int p2 = pages2[number]; + +#pragma omp critical + { + processed++; + statusLabel->setText(tr("Comparing %1/%2").arg(processed).arg(total)); + writeLine(tr("Comparing: %1 vs. %2.").arg(p1 + 1).arg(p2 + 1)); + QApplication::processEvents(); + } + + if (!cancel) { + + PdfPage page1(pdf1->page(p1)); + if (!page1) { +#pragma omp critical + writeError(tr("Failed to read page %1 from '%2'.").arg(p1 + 1).arg(filename1)); + continue; + } + + PdfPage page2(pdf2->page(p2)); + if (!page2) { +#pragma omp critical + writeError(tr("Failed to read page %1 from '%2'.").arg(p2 + 1).arg(filename2)); + continue; + } + + difference[number] = getTheDifference(page1, page2); + } } + + if (!cancel) { + + for (number = 0; number < total; number++) { + + int p1 = pages1.takeFirst(); + int p2 = pages2.takeFirst(); + + if (difference[number] != NoDifference) { + QVariant v; + v.setValue(PagePair(p1, p2, difference[number] == VisualDifference)); + viewDiffComboBox->addItem(tr("%1 vs. %2 %3 %4").arg(p1 + 1).arg(p2 + 1).arg(QChar(0x2022)).arg(++index), v); + } + } + } + return qMakePair(number, total); } Index: diffpdf-2.1.3/diffpdf.pro =================================================================== --- diffpdf-2.1.3.orig/diffpdf.pro 2013-10-15 09:01:22.000000000 +0200 +++ diffpdf-2.1.3/diffpdf.pro 2017-10-04 15:35:13.152649399 +0200 @@ -32,6 +32,9 @@ TRANSLATIONS += diffpdf_es.ts CODECFORTR = UTF-8 LIBS += -lpoppler-qt4 +QMAKE_CFLAGS += -fopenmp +QMAKE_CXXFLAGS += -fopenmp +QMAKE_LFLAGS += -fopenmp win32 { CONFIG += release }