aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-02-28 09:46:06 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-28 09:48:17 -0800
commitdfa0b12a44c6cd434de612db2c6b5573ef4e64bb (patch)
treef601c579874ebcbeee6881c1e274b194f6ac9550 /src/test/java/com/google/devtools/build/lib/profiler/ProfilerTest.java
parent1fe23126d4a30d49b7668b235ea1bfb2e2c8a39e (diff)
Add functionality to MemoryProfiler to do multiple garbage collections at the end of the build in an effort to get an accurate measurement of used memory.
PiperOrigin-RevId: 187337487
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.java32
1 files changed, 19 insertions, 13 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 2f988dd96a..ffc7e7f31a 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
@@ -308,19 +308,25 @@ public class ProfilerTest extends FoundationTestCase {
thread1.join();
clock.advanceMillis(1);
profiler.markPhase(ProfilePhase.ANALYZE);
- Thread thread2 = new Thread() {
- @Override public void run() {
- profiler.startTask(ProfilerTask.TEST, "complex task");
- for (int i = 0; i < 100; i++) {
- Profiler.instance().logEvent(ProfilerTask.TEST, "thread2a");
- }
- profiler.completeTask(ProfilerTask.TEST);
- profiler.markPhase(ProfilePhase.EXECUTE);
- for (int i = 0; i < 100; i++) {
- Profiler.instance().logEvent(ProfilerTask.TEST, "thread2b");
- }
- }
- };
+ Thread thread2 =
+ new Thread() {
+ @Override
+ public void run() {
+ profiler.startTask(ProfilerTask.TEST, "complex task");
+ for (int i = 0; i < 100; i++) {
+ Profiler.instance().logEvent(ProfilerTask.TEST, "thread2a");
+ }
+ profiler.completeTask(ProfilerTask.TEST);
+ try {
+ profiler.markPhase(ProfilePhase.EXECUTE);
+ } catch (InterruptedException e) {
+ throw new IllegalStateException(e);
+ }
+ for (int i = 0; i < 100; i++) {
+ Profiler.instance().logEvent(ProfilerTask.TEST, "thread2b");
+ }
+ }
+ };
thread2.start();
thread2.join();
profiler.logEvent(ProfilerTask.TEST, "last task");