From cd19655cd78e22dc8c38271624f7e2aabbbda2fc Mon Sep 17 00:00:00 2001 From: harlekin <5800926-mw102@users.noreply.gitlab.com> Date: Fri, 26 May 2023 21:05:23 +0000 Subject: [PATCH] Fix/rendertime detection --- src/main/java/com/sheepit/client/Job.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sheepit/client/Job.java b/src/main/java/com/sheepit/client/Job.java index d1d6a8e..d497d46 100644 --- a/src/main/java/com/sheepit/client/Job.java +++ b/src/main/java/com/sheepit/client/Job.java @@ -38,6 +38,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; +import java.time.LocalTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -389,6 +390,8 @@ import java.util.regex.Pattern; Pattern progressPattern = Pattern.compile(" (Rendered|Path Tracing Tile|Rendering|Sample) (\\d+)\\s?\\/\\s?(\\d+)( Tiles| samples|,)*"); Pattern beginScenePrepPattern = Pattern.compile(POST_LOAD_NOTIFICATION); Pattern beginPostProcessingPattern = Pattern.compile("^Fra:\\d* \\w*(.)* \\| (Compositing|Denoising)"); + Pattern savingPattern = Pattern.compile("Time: \\d\\d:\\d\\d.\\d\\d \\(Saving: (\\d\\d:\\d\\d.\\d\\d)"); + int savingTimeSeconds = -1; Instant timeStamp = null; Duration phaseDuration; //We divide the job into 3 phases: preparation, rendering, compositing boolean scenePrepStarted = false; @@ -441,6 +444,14 @@ import java.util.regex.Pattern; process.setRenderDuration((int) phaseDuration.toSeconds()); } + Matcher savingTimeDetector = savingPattern.matcher(line); + if (savingTimeDetector.find()) { + String savingTime = savingTimeDetector.group(1); + if (savingTime != null) { + savingTimeSeconds = (int) Duration.between(LocalTime.MIN, LocalTime.parse("00:" + savingTime)).toSeconds(); //add leading hours to comply with ISO time format + } + } + if (configuration.getMaxAllowedMemory() != -1 && getProcessRender().getMemoryUsed().get() > configuration.getMaxAllowedMemory()) { log.debug("Blocking render because process ram used (" + getProcessRender().getMemoryUsed().get() + "k) is over user setting (" + configuration .getMaxAllowedMemory() + "k)"); @@ -502,9 +513,15 @@ import java.util.regex.Pattern; if (timeStamp == null) { timeStamp = new Date(process.getStartTime()).toInstant(); } + if (postProcessingStarted == false) { phaseDuration = Duration.between(timeStamp, Instant.now()); process.setRenderDuration((int) phaseDuration.toSeconds()); + + //we need to subtract the time to save the frame to disk + if (savingTimeSeconds > 0 && process.getRenderDuration() > 0) { + process.setRenderDuration(Math.max(0, process.getRenderDuration() - savingTimeSeconds)); + } } else { phaseDuration = Duration.between(timeStamp, Instant.now()); @@ -512,7 +529,7 @@ import java.util.regex.Pattern; } input.close(); - log.debug(String.format("render times: %n\tScene prep: %ds%n\tRendering: %ss%n\tPost: %ss%n\tTotal: %ds%n\tRendering/Total: %.03f%n", + log.debug(String.format("render times: %n\tScene prep: %ds%n\tRendering: %ds%n\tPost: %ss%n\tTotal: %ds%n\tRendering/Total: %.03f%n", process.getScenePrepDuration(), process.getRenderDuration(), process.getPostProcessingDuration(),