diff --git a/src/main/java/org/gradle/profiler/report/JsonResultWriter.java b/src/main/java/org/gradle/profiler/report/JsonResultWriter.java index 2c25a83d..1e958f1c 100644 --- a/src/main/java/org/gradle/profiler/report/JsonResultWriter.java +++ b/src/main/java/org/gradle/profiler/report/JsonResultWriter.java @@ -96,6 +96,7 @@ private JsonObject serializeScenarioResult(Bui private JsonObject serializeSample(BuildScenarioResult scenarioResult, Sample sample) { JsonObject json = new JsonObject(); json.addProperty("name", sample.getName()); + json.addProperty("unit", sample.getUnit()); return json; } diff --git a/src/main/java/org/gradle/profiler/result/Sample.java b/src/main/java/org/gradle/profiler/result/Sample.java index 0d2ffbe0..d1609c21 100644 --- a/src/main/java/org/gradle/profiler/result/Sample.java +++ b/src/main/java/org/gradle/profiler/result/Sample.java @@ -3,5 +3,7 @@ public interface Sample { String getName(); + String getUnit(); + double extractFrom(T result); } diff --git a/src/main/java/org/gradle/profiler/result/TimeSample.java b/src/main/java/org/gradle/profiler/result/TimeSample.java index d662b312..8860eabb 100644 --- a/src/main/java/org/gradle/profiler/result/TimeSample.java +++ b/src/main/java/org/gradle/profiler/result/TimeSample.java @@ -4,6 +4,11 @@ public abstract class TimeSample implements Sample { + @Override + public String getUnit() { + return "ms"; + } + @Override public double extractFrom(T result) { return getDuration(result).toNanos() / 1000000d; diff --git a/src/main/js/org/gradle/profiler/report/report.js b/src/main/js/org/gradle/profiler/report/report.js index 5c5960f1..55b4bdeb 100644 --- a/src/main/js/org/gradle/profiler/report/report.js +++ b/src/main/js/org/gradle/profiler/report/report.js @@ -156,7 +156,6 @@ new Vue({ sample.color = `hsl(${scenarioIndex * 360 / scenarios.length}, ${100 - 80 * sampleIndex / samples.length}%, ${30 + 40 * sampleIndex / samples.length}%)`; sample.thickness = sampleIndex === 0 ? 3 : 2; sample.selected = sampleIndex === 0; - sample.unit = "ms"; const data = measuredIterations(scenario).map(iteration => iteration.values[sample.name]); OPERATIONS.forEach(operation => sample[operation.name] = operation.apply(data)); }); diff --git a/src/test/groovy/org/gradle/profiler/report/JsonResultWriterTest.groovy b/src/test/groovy/org/gradle/profiler/report/JsonResultWriterTest.groovy index aa7bb3d1..c0777282 100644 --- a/src/test/groovy/org/gradle/profiler/report/JsonResultWriterTest.groovy +++ b/src/test/groovy/org/gradle/profiler/report/JsonResultWriterTest.groovy @@ -138,10 +138,12 @@ class JsonResultWriterTest extends Specification { }, "samples": [ { - "name": "execution" + "name": "execution", + "unit": "ms" }, { - "name": "Test sample" + "name": "Test sample", + "unit": "ms" } ], "iterations": [ @@ -236,10 +238,12 @@ class JsonResultWriterTest extends Specification { }, "samples": [ { - "name": "execution" + "name": "execution", + "unit": "ms" }, { - "name": "Test sample" + "name": "Test sample", + "unit": "ms" } ], "iterations": [ diff --git a/src/test/resources/org/gradle/profiler/report/example-regression.json b/src/test/resources/org/gradle/profiler/report/example-regression.json index e1dde693..b97fb18b 100644 --- a/src/test/resources/org/gradle/profiler/report/example-regression.json +++ b/src/test/resources/org/gradle/profiler/report/example-regression.json @@ -45,7 +45,7 @@ "samples": [ { "name": "execution", - "confidence": 0.0 + "unit": "ms" } ], "iterations": [ @@ -289,7 +289,7 @@ "samples": [ { "name": "execution", - "confidence": 0.9991642831782728 + "unit": "ms" } ], "iterations": [ diff --git a/src/test/resources/org/gradle/profiler/report/example-single.json b/src/test/resources/org/gradle/profiler/report/example-single.json index a56398fb..c9e6e473 100644 --- a/src/test/resources/org/gradle/profiler/report/example-single.json +++ b/src/test/resources/org/gradle/profiler/report/example-single.json @@ -45,7 +45,7 @@ "samples": [ { "name": "execution", - "confidence": 0.0 + "unit": "ms" } ], "iterations": [ diff --git a/src/test/resources/org/gradle/profiler/report/example-with-build-operations.json b/src/test/resources/org/gradle/profiler/report/example-with-build-operations.json index 684506e9..1bb53ce0 100644 --- a/src/test/resources/org/gradle/profiler/report/example-with-build-operations.json +++ b/src/test/resources/org/gradle/profiler/report/example-with-build-operations.json @@ -45,39 +45,39 @@ "samples": [ { "name": "execution", - "confidence": 0.0 + "unit": "ms" }, { "name": "ResolveConfigurationDependenciesBuildOperationType", - "confidence": 0.0 + "unit": "ms" }, { "name": "DefaultTransformer$FingerprintTransformInputsOperation", - "confidence": 0.0 + "unit": "ms" }, { "name": "CaptureStateBeforeExecutionStep$Operation", - "confidence": 0.0 + "unit": "ms" }, { "name": "BuildCacheArchivePackBuildOperationType", - "confidence": 0.0 + "unit": "ms" }, { "name": "BuildCacheArchiveUnpackBuildOperationType", - "confidence": 0.0 + "unit": "ms" }, { "name": "SnapshotOutputsStep$Operation", - "confidence": 0.0 + "unit": "ms" }, { "name": "ExecuteTaskActionBuildOperationType", - "confidence": 0.0 + "unit": "ms" }, { "name": "ExecuteTaskBuildOperationType", - "confidence": 0.0 + "unit": "ms" } ], "iterations": [ @@ -497,39 +497,39 @@ "samples": [ { "name": "execution", - "confidence": 0.9991642831782728 + "unit": "ms" }, { "name": "ResolveConfigurationDependenciesBuildOperationType", - "confidence": 0.7023232455278197 + "unit": "ms" }, { "name": "DefaultTransformer$FingerprintTransformInputsOperation", - "confidence": 0.13956902626472267 + "unit": "ms" }, { "name": "CaptureStateBeforeExecutionStep$Operation", - "confidence": 0.9999999011729629 + "unit": "ms" }, { "name": "BuildCacheArchivePackBuildOperationType", - "confidence": 0.0 + "unit": "ms" }, { "name": "BuildCacheArchiveUnpackBuildOperationType", - "confidence": 0.0 + "unit": "ms" }, { "name": "SnapshotOutputsStep$Operation", - "confidence": 0.10758613603151901 + "unit": "ms" }, { "name": "ExecuteTaskActionBuildOperationType", - "confidence": 0.18185053861180012 + "unit": "ms" }, { "name": "ExecuteTaskBuildOperationType", - "confidence": 0.9999987143919465 + "unit": "ms" } ], "iterations": [ diff --git a/src/test/resources/org/gradle/profiler/report/example.json b/src/test/resources/org/gradle/profiler/report/example.json index 2c0681a5..cdb8eca5 100644 --- a/src/test/resources/org/gradle/profiler/report/example.json +++ b/src/test/resources/org/gradle/profiler/report/example.json @@ -45,7 +45,7 @@ "samples": [ { "name": "execution", - "confidence": 0.0 + "unit": "ms" } ], "iterations": [ @@ -289,7 +289,7 @@ "samples": [ { "name": "execution", - "confidence": 0.9991642831782728 + "unit": "ms" } ], "iterations": [