Skip to content

Commit

Permalink
impl. timer
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Mar 8, 2024
1 parent 77708d0 commit a67fb25
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.github.clagomess.pirilampo.core.dto.FeatureMetadataDto;
import com.github.clagomess.pirilampo.core.dto.ParametersDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.input.BOMInputStream;

import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
Expand All @@ -18,6 +20,7 @@
import static com.github.clagomess.pirilampo.core.enums.CompilationTypeEnum.FOLDER;
import static com.github.clagomess.pirilampo.core.enums.CompilationTypeEnum.FOLDER_DIFF;

@Slf4j
public abstract class Compiler {
public String getFeatureExtension(File f){
Matcher matcher = Pattern.compile("\\.feature$", Pattern.CASE_INSENSITIVE)
Expand Down Expand Up @@ -146,4 +149,13 @@ public File getAbsolutePathFeatureAsset(ParametersDto parameters, File feature,

return null;
}

private long initTimer;
protected void startTimer(){
initTimer = Instant.now().toEpochMilli();
}

protected void stopTimer(){
log.info("Compilation time: {}ms", Instant.now().toEpochMilli() - initTimer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public FeatureToHTMLCompiler(ParametersDto parameters) {
}

public void build() throws Exception {
startTimer();
GherkinDocumentParser gherkinDocumentParser = new GherkinDocumentParser(parameters, feature);

try (
Expand Down Expand Up @@ -55,6 +56,6 @@ public void build() throws Exception {
out.print("</div></div></div></body></html>");
}

// @TODO: add done and took
stopTimer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public FeatureToPDFCompiler(ParametersDto parameters) {
}

public void build() throws Exception {
startTimer();

File bufferHtml = File.createTempFile("pirilampo-buffer-", ".html");
log.info("Created buffer file: {}", bufferHtml);
File outArtifact = getOutArtifact(parameters);
Expand Down Expand Up @@ -83,6 +85,6 @@ public void build() throws Exception {
throw e;
}

// @TODO: add done and took
stopTimer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ protected void buildIndex(PrintWriter out) throws JsonProcessingException {
}

public void build() throws Exception {
MenuParser menuParser = new MenuParser(parameters);
startTimer();

MenuParser menuParser = new MenuParser(parameters);
Set<File> arquivos = listFolder(parameters.getProjectSource());
if(arquivos.isEmpty()) return;

Expand Down Expand Up @@ -220,6 +221,6 @@ public void build() throws Exception {
out.print("</body></html>");
}

// @TODO: add done and took
stopTimer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public FolderToPDFCompiler(ParametersDto parameters) {
}

public void build() throws Exception {
startTimer();

Set<File> arquivos = listFolder(parameters.getProjectSource());
if(arquivos.isEmpty()) return;

Expand Down Expand Up @@ -96,7 +98,6 @@ public void build() throws Exception {
throw e;
}

// @TODO: add done and took
// @TODO: attach HTML at END
stopTimer();
}
}

0 comments on commit a67fb25

Please sign in to comment.