Skip to content

Commit

Permalink
Use milliseconds for JSON report
Browse files Browse the repository at this point in the history
For the JSON report milliseconds are used. Having only one unit (ms)
makes it easier to reuse the timing results.

See: #4
  • Loading branch information
Benjamin Herbert committed Aug 5, 2015
1 parent 81427af commit 99c46cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/fr/jcgay/maven/profiler/ProfilerEventSpy.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ private String getJSONRepresentation(Data context) {
for (Project project : context.getProjects()) {
JsonObject projectObj = new JsonObject();
projectObj.add("project", project.getName());
projectObj.add("time", project.getTime().toString());
projectObj.add("time", project.getMillisTimeStamp());
JsonArray projectMojosArr = new JsonArray();
for (EntryAndTime entry : project.getMojosWithTime()) {
JsonObject projectMojoObj = new JsonObject();
projectMojoObj.add("mojo", entry.getEntry().toString());
projectMojoObj.add("time", entry.getTime().toString());
projectMojoObj.add("time", entry.getMillisTimeStamp());
projectMojosArr.add(projectMojoObj);
}
projectObj.add("mojos", projectMojosArr);
Expand All @@ -309,7 +309,7 @@ private String getJSONRepresentation(Data context) {
for (EntryAndTime download : context.getDownloads()) {
JsonObject downloadObj = new JsonObject();
downloadObj.add("download", download.getEntry().toString());
downloadObj.add("time", download.getTime().toString());
downloadObj.add("time", download.getMillisTimeStamp());
downloadsArr.add(downloadObj);
}
obj.add("downloads", downloadsArr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ public T getEntry() {
public Stopwatch getTime() {
return time;
}

public String getMillisTimeStamp() {
return String.valueOf(time.elapsedMillis()) + " ms";
}
}
4 changes: 4 additions & 0 deletions src/main/java/fr/jcgay/maven/profiler/template/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public List<EntryAndTime<MojoExecution>> getMojosWithTime() {
public Stopwatch getTime() {
return time;
}

public String getMillisTimeStamp() {
return String.valueOf(time.elapsedMillis()) + " ms";
}
}

0 comments on commit 99c46cd

Please sign in to comment.