RED-6126: performance-test
*added PDFNet terminate
This commit is contained in:
parent
8db0b712f7
commit
e2c0be95d5
@ -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());
|
||||
|
||||
@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.ocr.v1.api.model.DocumentRequest;
|
||||
import com.iqser.red.service.ocr.v1.server.client.FileStatusProcessingUpdateClient;
|
||||
import com.iqser.red.service.ocr.v1.server.configuration.MessagingConfiguration;
|
||||
import com.pdftron.pdf.PDFNet;
|
||||
|
||||
import feign.FeignException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -57,11 +58,12 @@ public class OcrMessageReceiver {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("Successfully processed ocr for file with dossierId {} and fileId {}, took {}", ocrRequestMessage.getDossierId(), ocrRequestMessage.getFileId(), end - start);
|
||||
|
||||
fileStatusProcessingUpdateClient.ocrSuccessful(ocrRequestMessage.getDossierId(), ocrRequestMessage.getFileId());
|
||||
|
||||
PDFNet.terminate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user