use of com.facebook.buck.util.perf.ProcessTracker.ProcessResourceConsumptionEvent in project buck by facebook.
the class ProcessTrackerTest method createProcessTracker.
private ProcessTrackerForTest createProcessTracker(final BlockingQueue<ProcessResourceConsumptionEvent> events) {
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
eventBus.register(new Object() {
@Subscribe
public void event(ProcessResourceConsumptionEvent event) {
events.add(event);
}
});
return new ProcessTrackerForTest(eventBus, FakeInvocationInfoFactory.create(), processHelper, processRegistry);
}
use of com.facebook.buck.util.perf.ProcessTracker.ProcessResourceConsumptionEvent in project buck by facebook.
the class ProcessTrackerTest method pollEvents.
private static List<ProcessResourceConsumptionEvent> pollEvents(BlockingQueue<ProcessResourceConsumptionEvent> events) throws Exception {
List<ProcessResourceConsumptionEvent> res = new ArrayList<>();
while (!events.isEmpty()) {
ProcessResourceConsumptionEvent event = events.poll(0, TimeUnit.MILLISECONDS);
res.add(event);
}
return res;
}
use of com.facebook.buck.util.perf.ProcessTracker.ProcessResourceConsumptionEvent in project buck by facebook.
the class ProcessTrackerTest method testThisProcessInfo.
@Test
public void testThisProcessInfo() throws Exception {
BlockingQueue<ProcessResourceConsumptionEvent> events = new LinkedBlockingQueue<>();
try (ProcessTrackerForTest processTracker = createProcessTracker(events)) {
ProcessResourceConsumption res1 = createConsumption(42, 3, 0);
processHelper.setProcessResourceConsumption(123, res1);
ProcessTracker.ThisProcessInfo info1 = processTracker.new ThisProcessInfo(123, "proc1");
assertFalse(info1.hasProcessFinished());
testProcessInfo(info1, 123, "proc1", Optional.empty(), res1, events);
ProcessTracker.ThisProcessInfo info2 = processTracker.new ThisProcessInfo(200, "proc2");
assertFalse(info2.hasProcessFinished());
testProcessInfo(info2, 200, "proc2", Optional.empty(), null, events);
}
}
use of com.facebook.buck.util.perf.ProcessTracker.ProcessResourceConsumptionEvent in project buck by facebook.
the class ProcessTrackerTest method dumpEvents.
private static void dumpEvents(BlockingQueue<ProcessResourceConsumptionEvent> events) {
System.err.println("Dumping events: " + events.size());
for (ProcessResourceConsumptionEvent event : events) {
System.err.println("{'" + event.getExecutableName() + "', " + event.getParams() + "}");
}
System.err.println("");
}
use of com.facebook.buck.util.perf.ProcessTracker.ProcessResourceConsumptionEvent in project buck by facebook.
the class ProcessTrackerTest method testExternalProcessInfo.
@Test
public void testExternalProcessInfo() throws Exception {
BlockingQueue<ProcessResourceConsumptionEvent> events = new LinkedBlockingQueue<>();
try (ProcessTrackerForTest processTracker = createProcessTracker(events)) {
FakeNuProcess proc1 = new FakeNuProcess(111);
ProcessResourceConsumption res1 = createConsumption(42, 3, 0);
processHelper.setProcessResourceConsumption(111, res1);
ProcessTracker.ExternalProcessInfo info1 = processTracker.new ExternalProcessInfo(111, proc1, createParams("proc1"), CONTEXT);
assertFalse(info1.hasProcessFinished());
testProcessInfo(info1, 111, "proc1", Optional.of(createParams("proc1")), res1, events);
FakeNuProcess proc2 = new FakeNuProcess(222);
ProcessTracker.ExternalProcessInfo info2 = processTracker.new ExternalProcessInfo(222, proc2, createParams("proc2"), CONTEXT);
assertFalse(info2.hasProcessFinished());
testProcessInfo(info2, 222, "proc2", Optional.of(createParams("proc2")), null, events);
proc1.finish(-3);
assertTrue(info1.hasProcessFinished());
}
}
Aggregations