use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testQueryMipMax.
/**
* Test a single query to the state system for a max
*
* Make sure the state system has data.
*
* Hint: the value read should always be greater than(t / 1000)
*/
@Test
public void testQueryMipMax() {
assertNotNull(ssq);
try {
List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MAX_STRING);
assertEquals("max nblevels", NB_LEVELS, intervals.get(mipmapQuark).getStateValue().unboxInt());
for (int level = 1; level < NB_LEVELS; level++) {
long width = (long) Math.pow(RESOLUTION, level);
int levelQuark = ssq.getQuarkRelative(mipmapQuark, String.valueOf(level));
ITmfStateInterval interval = intervals.get(levelQuark);
long valueLong = interval.getStateValue().unboxLong();
assertEquals("max value @ level " + level, width + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width, valueLong);
assertEquals("max start time @ level " + level, START_TIME + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getStartTime());
assertEquals("max end time @ level " + level, START_TIME + (INTERVAL * width) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getEndTime() + 1);
}
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testMaxLevel.
/**
* Test a single query to the state system for the maxLevel.
*
* Make sure the state system has data.
*/
@Test
public void testMaxLevel() {
assertNotNull(ssq);
try {
Random rn = new Random();
long time = Math.max(INTERVAL, rn.nextLong() % END_TIME);
List<ITmfStateInterval> intervals = ssq.queryFullState(time);
int maxMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MAX_STRING);
int nbLevelMax = intervals.get(maxMipmapQuark).getStateValue().unboxInt();
assertEquals(NB_LEVELS, nbLevelMax);
int minMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MIN_STRING);
int nbLevelMin = intervals.get(minMipmapQuark).getStateValue().unboxInt();
assertEquals(NB_LEVELS, nbLevelMin);
int avgMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.AVG_STRING);
int nbLevelAvg = intervals.get(avgMipmapQuark).getStateValue().unboxInt();
assertEquals(NB_LEVELS, nbLevelAvg);
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testQueryEventField.
/**
* Test a single query to the state system for a mip
*
* Make sure the state system has data.
*/
@Test
public void testQueryEventField() {
assertNotNull(ssq);
try {
List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
int eventFieldQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
ITmfStateInterval interval = intervals.get(eventFieldQuark);
long valueLong = interval.getStateValue().unboxLong();
assertEquals(TEST_TIMESTAMP / INTERVAL, valueLong);
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testQueryMipMin.
/**
* Test a single query to the state system for a min
*
* Make sure the state system has data.
*
* Hint: the value read should always be less than(t / 1000)
*/
@Test
public void testQueryMipMin() {
assertNotNull(ssq);
try {
List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MIN_STRING);
assertEquals("min nblevels", NB_LEVELS, intervals.get(mipmapQuark).getStateValue().unboxInt());
for (int level = 1; level < NB_LEVELS; level++) {
long width = (long) Math.pow(RESOLUTION, level);
int levelQuark = ssq.getQuarkRelative(mipmapQuark, String.valueOf(level));
ITmfStateInterval interval = intervals.get(levelQuark);
long valueLong = interval.getStateValue().unboxLong();
assertEquals("min value @ level " + level, 1 + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width, valueLong);
assertEquals("min start time @ level " + level, START_TIME + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getStartTime());
assertEquals("min end time @ level " + level, START_TIME + (INTERVAL * width) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getEndTime() + 1);
}
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method testQueryMipAvg.
/**
* Test a single query to the state system for an average
*
* Make sure the state system has data.
*
* Hint: the value read should always be more or less(t / 1000)
*/
@Test
public void testQueryMipAvg() {
assertNotNull(ssq);
try {
List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.AVG_STRING);
assertEquals("avg nblevels", NB_LEVELS, intervals.get(mipmapQuark).getStateValue().unboxInt());
for (int level = 1; level < NB_LEVELS; level++) {
long width = (long) Math.pow(RESOLUTION, level);
int levelQuark = ssq.getQuarkRelative(mipmapQuark, String.valueOf(level));
ITmfStateInterval interval = intervals.get(levelQuark);
double valueDouble = interval.getStateValue().unboxDouble();
assertEquals("avg value @ level " + level, 0.5 + (width / 2) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width, valueDouble, DELTA);
assertEquals("avg start time @ level " + level, START_TIME + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getStartTime());
assertEquals("avg end time @ level " + level, START_TIME + (INTERVAL * width) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getEndTime() + 1);
}
} catch (TimeRangeException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateValueTypeException e) {
fail(e.getMessage());
}
assertTrue(true);
}
Aggregations