Skip to content

Commit

Permalink
Merge pull request #101 from alkakumari016/Fix_100
Browse files Browse the repository at this point in the history
"Fix issue #100"
  • Loading branch information
justynapt authored Jan 25, 2024
2 parents 2359f57 + e121b87 commit a8950da
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/main/java/gin/util/MemoryProfiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.sampullara.cli.Argument;
import gin.test.UnitTest;

import gin.util.enums.ProfilerChoice;
import org.apache.commons.lang3.SystemUtils;
import org.pmw.tinylog.Logger;

Expand Down Expand Up @@ -63,9 +64,9 @@ public class MemoryProfiler {
@Argument(alias = "hi", description = "Interval for hprof's CPU sampling in milliseconds")
protected Long hprofInterval = 1L;
@Argument(alias = "prof", description = "Profiler to use: JFR or HPROF. Default is JFR")
protected String profilerChoice = "jfr";
protected String profilerChoice = String.valueOf(ProfilerChoice.JFR);
@Argument(alias = "save", description = "Save individual profiling files, default is delete, set command as 's' to save")
protected String saveChoice = "d";
protected boolean saveChoice = false;

public MemoryProfiler(String[] args) {
Args.parseOrExit(this, args);
Expand Down Expand Up @@ -273,7 +274,7 @@ protected List<MemoryTrace> parseMemoryTraces(Set<UnitTest> tests) {


//delete individual profiling files
if (saveChoice.equals("d")) {
if (!saveChoice) {
try {
Files.deleteIfExists(traceFile.toPath());
} catch (IOException e) {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/gin/util/Profiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.sampullara.cli.Args;
import com.sampullara.cli.Argument;
import gin.test.UnitTest;
import gin.util.enums.ProfilerChoice;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.file.PathUtils;
import org.apache.commons.lang3.SystemUtils;
Expand Down Expand Up @@ -65,9 +66,9 @@ public class Profiler implements Serializable {
@Argument(alias = "hi", description = "Interval for hprof's CPU sampling in milliseconds")
protected Long hprofInterval = 10L;
@Argument(alias = "prof", description = "Profiler to use: JFR or HPROF. Default is JFR")
protected String profilerChoice = "jfr";
protected String profilerChoice = String.valueOf(ProfilerChoice.JFR);
@Argument(alias = "save", description = "Save individual profiling files, default is delete, set command as 's' to save")
protected String saveChoice = "d";
protected boolean saveChoice = false;

public Profiler(String[] args) {
Args.parseOrExit(this, args);
Expand Down Expand Up @@ -275,7 +276,7 @@ protected List<Trace> parseTraces(Set<UnitTest> tests) {
}

//delete individual profiling files
if (saveChoice.equals("d")) {
if (!saveChoice) {
try {
Files.deleteIfExists(traceFile.toPath());
} catch (IOException e) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gin/util/RTSProfiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.sampullara.cli.Args;
import com.sampullara.cli.Argument;
import gin.test.UnitTest;
import gin.util.enums.ProfilerChoice;
import gin.util.regression.RTSFactory;
import gin.util.regression.RTSStrategy;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -76,7 +77,7 @@ public class RTSProfiler implements Serializable {
@Argument(alias = "pn", description = "Java profiler file name. If running in parallel, use a different name for each job.")
protected String profFileName = "java.prof.jfr";
@Argument(alias = "prof", description = "Profiler to use: jfr or hprof. Default is jfr")
protected String profilerChoice = "jfr";
protected String profilerChoice = String.valueOf(ProfilerChoice.JFR);
protected Project project;

public RTSProfiler(String[] args) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/gin/util/enums/ProfileChoice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package gin.util.enums;

public enum ProfilerChoice {
JFR,
HPROF
}

0 comments on commit a8950da

Please sign in to comment.