use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.
the class FDBStoreTimerTest method timerConstraintChecks.
@Test
public void timerConstraintChecks() {
// invalid to substract a snapshot timer from a timer that has been reset after the snapshot was taken
FDBStoreTimer latestTimer = context.getTimer();
final StoreTimerSnapshot savedTimer;
savedTimer = StoreTimerSnapshot.from(latestTimer);
latestTimer.reset();
assertThrows(RecordCoreArgumentException.class, () -> StoreTimer.getDifference(latestTimer, savedTimer));
// invalid to subtract a snapshot timer from a timer it was not derived from
StoreTimer anotherStoreTimer = new StoreTimer();
assertThrows(RecordCoreArgumentException.class, () -> StoreTimer.getDifference(anotherStoreTimer, savedTimer));
}
use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.
the class FDBStoreTimerTest method newMetricsAddedToSnapshotDifference.
@Test
public void newMetricsAddedToSnapshotDifference() {
StoreTimer timer = new FDBStoreTimer();
timer.increment(FDBStoreTimer.Counts.DELETE_RECORD_KEY);
StoreTimerSnapshot snapshot = StoreTimerSnapshot.from(timer);
timer.increment(FDBStoreTimer.Counts.DELETE_RECORD_KEY);
timer.record(FDBStoreTimer.Events.DIRECTORY_READ, 7L);
StoreTimer diff = StoreTimer.getDifference(timer, snapshot);
assertThat(diff.getCounter(FDBStoreTimer.Counts.DELETE_RECORD_KEY).getCount(), Matchers.is(1));
assertThat(diff.getCounter(FDBStoreTimer.Counts.DELETE_RECORD_KEY).getTimeNanos(), Matchers.is(0L));
assertThat(diff.getCounter(FDBStoreTimer.Events.DIRECTORY_READ).getCount(), Matchers.is(1));
assertThat(diff.getCounter(FDBStoreTimer.Events.DIRECTORY_READ).getTimeNanos(), Matchers.is(7L));
}
use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.
the class FDBStoreTimerTest method unchangedMetricsExcludedFromSnapshotDifference.
@Test
public void unchangedMetricsExcludedFromSnapshotDifference() {
StoreTimer timer = new FDBStoreTimer();
timer.increment(FDBStoreTimer.Counts.CREATE_RECORD_STORE);
timer.increment(FDBStoreTimer.Counts.DELETE_RECORD_KEY);
timer.record(FDBStoreTimer.Events.CHECK_VERSION, 1L);
timer.record(FDBStoreTimer.Events.DIRECTORY_READ, 3L);
StoreTimerSnapshot snapshot = StoreTimerSnapshot.from(timer);
timer.increment(FDBStoreTimer.Counts.DELETE_RECORD_KEY);
timer.record(FDBStoreTimer.Events.DIRECTORY_READ, 7L);
StoreTimer diff = StoreTimer.getDifference(timer, snapshot);
assertThat(diff.getCounter(FDBStoreTimer.Counts.CREATE_RECORD_STORE), Matchers.nullValue());
assertThat(diff.getCounter(FDBStoreTimer.Events.CHECK_VERSION), Matchers.nullValue());
assertThat(diff.getCounter(FDBStoreTimer.Counts.DELETE_RECORD_KEY).getCount(), Matchers.is(1));
assertThat(diff.getCounter(FDBStoreTimer.Counts.DELETE_RECORD_KEY).getTimeNanos(), Matchers.is(0L));
assertThat(diff.getCounter(FDBStoreTimer.Events.DIRECTORY_READ).getCount(), Matchers.is(1));
assertThat(diff.getCounter(FDBStoreTimer.Events.DIRECTORY_READ).getTimeNanos(), Matchers.is(7L));
}
use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.
the class QueryPlanStructuralInstrumentationTest method unionDifferentIndex.
@Test
public void unionDifferentIndex() {
final RecordQueryPlan plan = RecordQueryUnionPlan.from(indexPlanEquals("index_1", 2), indexPlanEquals("index_2", 4), EmptyKeyExpression.EMPTY, false);
assertUsesIndexes(plan, Lists.newArrayList("index_1", "index_2"));
final StoreTimer timer = new FDBStoreTimer();
plan.logPlanStructure(timer);
assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_UNION), 1);
assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_INDEX), 2);
}
use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.
the class QueryPlanStructuralInstrumentationTest method in.
@Test
public void in() {
final String indexName = "a_field";
final IndexScanParameters scan = IndexScanComparisons.byValue(new ScanComparisons(Arrays.asList(new Comparisons.ParameterComparison(Comparisons.Type.EQUALS, "another_field")), Collections.emptySet()));
final RecordQueryPlan plan = new RecordQueryInValuesJoinPlan(new RecordQueryIndexPlan(indexName, scan, false), "another_field", Bindings.Internal.IN, Arrays.asList(2, 4), false, false);
assertUsesIndexes(plan, Lists.newArrayList(indexName));
final StoreTimer timer = new FDBStoreTimer();
plan.logPlanStructure(timer);
assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_IN_VALUES), 1);
assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_INDEX), 1);
}
Aggregations