Fix/rendertime detection

This commit is contained in:
harlekin
2023-05-26 21:05:23 +00:00
parent b8c3e25c96
commit cd19655cd7

View File

@@ -38,6 +38,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.LocalTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; 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 progressPattern = Pattern.compile(" (Rendered|Path Tracing Tile|Rendering|Sample) (\\d+)\\s?\\/\\s?(\\d+)( Tiles| samples|,)*");
Pattern beginScenePrepPattern = Pattern.compile(POST_LOAD_NOTIFICATION); Pattern beginScenePrepPattern = Pattern.compile(POST_LOAD_NOTIFICATION);
Pattern beginPostProcessingPattern = Pattern.compile("^Fra:\\d* \\w*(.)* \\| (Compositing|Denoising)"); 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; Instant timeStamp = null;
Duration phaseDuration; //We divide the job into 3 phases: preparation, rendering, compositing Duration phaseDuration; //We divide the job into 3 phases: preparation, rendering, compositing
boolean scenePrepStarted = false; boolean scenePrepStarted = false;
@@ -441,6 +444,14 @@ import java.util.regex.Pattern;
process.setRenderDuration((int) phaseDuration.toSeconds()); 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()) { 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 log.debug("Blocking render because process ram used (" + getProcessRender().getMemoryUsed().get() + "k) is over user setting (" + configuration
.getMaxAllowedMemory() + "k)"); .getMaxAllowedMemory() + "k)");
@@ -502,9 +513,15 @@ import java.util.regex.Pattern;
if (timeStamp == null) { if (timeStamp == null) {
timeStamp = new Date(process.getStartTime()).toInstant(); timeStamp = new Date(process.getStartTime()).toInstant();
} }
if (postProcessingStarted == false) { if (postProcessingStarted == false) {
phaseDuration = Duration.between(timeStamp, Instant.now()); phaseDuration = Duration.between(timeStamp, Instant.now());
process.setRenderDuration((int) phaseDuration.toSeconds()); 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 { else {
phaseDuration = Duration.between(timeStamp, Instant.now()); phaseDuration = Duration.between(timeStamp, Instant.now());
@@ -512,7 +529,7 @@ import java.util.regex.Pattern;
} }
input.close(); 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.getScenePrepDuration(),
process.getRenderDuration(), process.getRenderDuration(),
process.getPostProcessingDuration(), process.getPostProcessingDuration(),