RED-6126: performance-test

*fixed time calculation
This commit is contained in:
Kilian Schuettler 2023-02-09 14:37:09 +01:00
parent 8db0b712f7
commit 7028baaaf5

View File

@ -72,7 +72,7 @@ public class OCRService {
invisibleElementRemovalService.removeInvisibleElements(fileStream, transferOutputStream, false);
}
long end = System.currentTimeMillis();
log.info("Invisible element removal successful for file with dossierId {} and fileId {}, took {}s", dossierId, fileId, format("%.1f", (float) ((end - start) / 1000)));
log.info("Invisible element removal successful for file with dossierId {} and fileId {}, took {}s", dossierId, fileId, format("%.1f", (end - start) / 1000.0));
try (InputStream transferInputStream = new ByteArrayInputStream(transferOutputStream.toByteArray())) {
runOcr(transferInputStream, out, fileId);
}
@ -93,12 +93,12 @@ public class OCRService {
Map<Integer, RectCollection> pageIdToRectCollection = imagePositionRetrievalService.getImagePositionPerPage(pdfDoc, true);
int numProcessedPages = 0;
// optimization: only scanning pages that contain images
for (Integer pageId : pageIdToRectCollection.keySet()) {
try {
// optimization: creating a new document is faster than reusing the same and adding/removing pages one by one
OCROptions options = new OCROptions();
PDFDoc ocrPageDoc = new PDFDoc();
// optimization: only scanning pages that contain images
Page pdfPage = pdfDoc.getPage(pageId);
// optimization: this line ensures the ocr text is placed correctly by PDFTron
pdfPage.setMediaBox(pdfPage.getCropBox());