aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2018-06-12 12:21:25 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-12 12:23:15 -0700
commit400fffe8b2df50c5b57ced5d9a8b46e40d529d4e (patch)
treea9a1291a0a05d4dee5c8e2ea9da092135c91a42f /src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java
parentc958649131ab8cf48a881aaddc50390cb7d79bfb (diff)
Add support for the Json trace file format
Add a --experimental_generate_json_trace_profile option that puts a file into the output base (or uses --profile if set). There are still a lot of problems with this. - unexplained holes - way too many threads - nonsensical event titles - too many detail events, too little overview - it may also cause unnecessary load - it silently overwrites the existing file on subsequent invocations The format is documented here: goo.gl/oMZPLh PiperOrigin-RevId: 200259431
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java b/src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java
index 0fee59186d..a52bc2e6e7 100644
--- a/src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java
@@ -15,6 +15,7 @@ package com.google.devtools.build.lib.profiler;
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.lib.profiler.Profiler.Format.BINARY_BAZEL_FORMAT;
+import static com.google.devtools.build.lib.profiler.Profiler.Format.JSON_TRACE_FILE_FORMAT;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static org.junit.Assert.fail;
@@ -573,7 +574,7 @@ public class ProfilerTest {
}
@Test
- public void testIOExceptionInOutputStream() throws Exception {
+ public void testIOExceptionInOutputStreamBinaryFormat() throws Exception {
OutputStream failingOutputStream = new OutputStream() {
@Override
public void write(int b) throws IOException {
@@ -597,4 +598,30 @@ public class ProfilerTest {
assertThat(expected).hasMessageThat().isEqualTo("Expected failure.");
}
}
+
+ @Test
+ public void testIOExceptionInOutputStreamJsonFormat() throws Exception {
+ OutputStream failingOutputStream = new OutputStream() {
+ @Override
+ public void write(int b) throws IOException {
+ throw new IOException("Expected failure.");
+ }
+ };
+ profiler.start(
+ ProfiledTaskKinds.ALL,
+ failingOutputStream,
+ JSON_TRACE_FILE_FORMAT,
+ "basic test",
+ false,
+ BlazeClock.instance(),
+ BlazeClock.instance().nanoTime());
+ profiler.logSimpleTaskDuration(
+ Profiler.nanoTimeMaybe(), Duration.ofSeconds(10), ProfilerTask.INFO, "foo");
+ try {
+ profiler.stop();
+ fail();
+ } catch (IOException expected) {
+ assertThat(expected).hasMessageThat().isEqualTo("Expected failure.");
+ }
+ }
}