Search in sources :

Example 11 with TimeRangeException

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);
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) StateValueTypeException(org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException) Test(org.junit.Test)

Example 12 with TimeRangeException

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);
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) Random(java.util.Random) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) StateValueTypeException(org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException) Test(org.junit.Test)

Example 13 with TimeRangeException

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);
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) StateValueTypeException(org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException) Test(org.junit.Test)

Example 14 with TimeRangeException

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);
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) StateValueTypeException(org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException) Test(org.junit.Test)

Example 15 with TimeRangeException

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);
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) StateValueTypeException(org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException) Test(org.junit.Test)

Aggregations

TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)55 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)41 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)40 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)22 AttributeNotFoundException (org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException)20 Test (org.junit.Test)17 StateValueTypeException (org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException)15 NonNull (org.eclipse.jdt.annotation.NonNull)13 ArrayList (java.util.ArrayList)12 Nullable (org.eclipse.jdt.annotation.Nullable)11 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)10 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)9 HashMap (java.util.HashMap)8 ITmfStateSystemBuilder (org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder)8 IStateHistoryBackend (org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend)8 AtomicLong (java.util.concurrent.atomic.AtomicLong)7 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)6 TimeGraphModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)6 List (java.util.List)5 TmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval)5