use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfExperimentTest method testExperimentInitialization.
// ------------------------------------------------------------------------
// Experiment setup
// ------------------------------------------------------------------------
@Test
public void testExperimentInitialization() {
/*
* Calling default constructor, then init should be equivalent to
* calling the full constructor
*/
TmfExperimentStub experiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, 5000);
experiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
assertEquals("GetId", EXPERIMENT, fExperiment.getName());
assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
final long nbExperimentEvents = fExperiment.getNbEvents();
assertEquals("GetNbEvents", NB_EVENTS, nbExperimentEvents);
final long nbTraceEvents = fExperiment.getTraces().get(0).getNbEvents();
assertEquals("GetNbEvents", NB_EVENTS, nbTraceEvents);
final TmfTimeRange timeRange = fExperiment.getTimeRange();
assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
experiment.dispose();
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfMultiTraceExperimentTest method testCancel.
// ------------------------------------------------------------------------
// cancel
// ------------------------------------------------------------------------
@Test
public void testCancel() throws InterruptedException {
final int nbEvents = NB_EVENTS;
final int limit = BLOCK_SIZE;
final Vector<ITmfEvent> requestedEvents = new Vector<>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {
int nbRead = 0;
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
if (++nbRead == limit) {
cancel();
}
}
};
fExperiment.sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", limit, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertTrue("isCancelled", request.isCancelled());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfMultiTraceExperimentTest method testBasicTmfExperimentConstructor.
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
@Test
public void testBasicTmfExperimentConstructor() {
assertEquals("GetId", EXPERIMENT, fExperiment.getName());
assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
final TmfTimeRange timeRange = fExperiment.getTimeRange();
assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
ITmfTimestamp initRange = TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE);
assertEquals("getInitialRangeOffset", initRange, fExperiment.getInitialRangeOffset());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfMultiTraceExperimentTest method testProcessRequestForAllEvents.
@Test
public void testProcessRequestForAllEvents() throws InterruptedException {
final int nbEvents = ITmfEventRequest.ALL_DATA;
final Vector<ITmfEvent> requestedEvents = new Vector<>();
final long nbExpectedEvents = NB_EVENTS;
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
fExperiment.sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertFalse("isCancelled", request.isCancelled());
// Don't go overboard: we are not validating the stub!
for (int i = 0; i < nbExpectedEvents; i++) {
assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
}
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfMultiTraceExperimentTest method testProcessRequestForNbEvents.
// ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
@Test
public void testProcessRequestForNbEvents() throws InterruptedException {
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
fExperiment.sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", nbEvents, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertFalse("isCancelled", request.isCancelled());
// Don't go overboard: we are not validating the stub!
for (int i = 0; i < nbEvents; i++) {
assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
}
}
Aggregations