use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.
the class BuckEventBusTest method timestampedEventHasSeparateNanosAndMillis.
@Test
public void timestampedEventHasSeparateNanosAndMillis() throws IOException {
SettableFakeClock fakeClock = new SettableFakeClock(49152, 64738);
BuckEventBus eb = new BuckEventBus(fakeClock, false, BuckEventBusFactory.BUILD_ID_FOR_TEST, timeoutMillis);
TestEvent event = new TestEvent();
eb.post(event);
eb.close();
assertEquals(event.getTimestamp(), 49152);
assertEquals(event.getNanoTime(), 64738);
}
use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.
the class SimplePerfEventTest method testMinimumTimeScope.
@Test
public void testMinimumTimeScope() throws Exception {
PerfEventId ignoredEventId = PerfEventId.of("IgnoreMe");
PerfEventId loggedEventId = PerfEventId.of("LogMe");
PerfEventId parentId = PerfEventId.of("Parent");
SimplePerfEventListener listener = new SimplePerfEventListener();
SettableFakeClock clock = new SettableFakeClock(0L, 0L);
BuckEventBus eventBus = BuckEventBusFactory.newInstance(clock);
eventBus.register(listener);
try (SimplePerfEvent.Scope parent = SimplePerfEvent.scope(eventBus, parentId)) {
clock.advanceTimeNanos(10L);
try (SimplePerfEvent.Scope scope = SimplePerfEvent.scopeIgnoringShortEvents(eventBus, ignoredEventId, parent, 1, TimeUnit.SECONDS)) {
clock.advanceTimeNanos(10L);
}
clock.advanceTimeNanos(10L);
try (SimplePerfEvent.Scope scope = SimplePerfEvent.scopeIgnoringShortEvents(eventBus, loggedEventId, parent, 1, TimeUnit.MILLISECONDS)) {
clock.advanceTimeNanos(TimeUnit.MILLISECONDS.toNanos(2));
}
}
ImmutableList<SimplePerfEvent> perfEvents = listener.getPerfEvents();
assertThat(perfEvents, Matchers.hasSize(4));
assertPerfEvent(perfEvents.get(0), parentId, SimplePerfEvent.Type.STARTED, ImmutableMap.of());
assertPerfEvent(perfEvents.get(1), loggedEventId, SimplePerfEvent.Type.STARTED, ImmutableMap.of());
assertPerfEvent(perfEvents.get(2), loggedEventId, SimplePerfEvent.Type.FINISHED, ImmutableMap.of());
assertPerfEvent(perfEvents.get(3), parentId, SimplePerfEvent.Type.FINISHED, ImmutableMap.of("IgnoreMe_accumulated_count", "1", "IgnoreMe_accumulated_duration_ns", "10"));
}
use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.
the class FakeProjectFilesystemTest method fileModifiedTimeIsUpdatedOnSubsequentWrite.
@Test
public void fileModifiedTimeIsUpdatedOnSubsequentWrite() throws IOException {
SettableFakeClock clock = new SettableFakeClock(49152, 0);
FakeProjectFilesystem filesystem = new FakeProjectFilesystem(clock);
filesystem.touch(Paths.get("foo"));
clock.setCurrentTimeMillis(64738);
filesystem.touch(Paths.get("foo"));
assertEquals(filesystem.getLastModifiedTime(Paths.get("foo")), 64738);
}
use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.
the class BuildTracesTest method testSortByLastModified.
@Test
public void testSortByLastModified() throws IOException {
SettableFakeClock clock = new SettableFakeClock(0L, 0L);
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem(clock);
clock.setCurrentTimeMillis(1);
Path traceDir = projectFilesystem.getBuckPaths().getTraceDir();
projectFilesystem.touch(traceDir.resolve("build.1.trace"));
clock.setCurrentTimeMillis(4);
projectFilesystem.touch(traceDir.resolve("build.4.trace"));
clock.setCurrentTimeMillis(2);
projectFilesystem.touch(traceDir.resolve("build.2.trace"));
clock.setCurrentTimeMillis(5);
projectFilesystem.touch(traceDir.resolve("build.5.trace"));
clock.setCurrentTimeMillis(3);
projectFilesystem.touch(traceDir.resolve("build.3.trace"));
projectFilesystem.touch(traceDir.resolve("build.3b.trace"));
BuildTraces helper = new BuildTraces(projectFilesystem);
assertEquals(ImmutableList.of(traceDir.resolve("build.5.trace"), traceDir.resolve("build.4.trace"), traceDir.resolve("build.3b.trace"), traceDir.resolve("build.3.trace"), traceDir.resolve("build.2.trace"), traceDir.resolve("build.1.trace")), helper.listTraceFilesByLastModified());
}
Aggregations