Search in sources :

Example 1 with TmfTreeModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.

the class InputOutputDataProviderTest method testDiskActivity.

/**
 * Test the data provider
 */
@Test
public void testDiskActivity() {
    DisksIODataProvider provider = getProvider();
    Collection<@NonNull DiskActivity> diskActivity = fTestCase.getDiskActivity();
    for (DiskActivity test : diskActivity) {
        Map<@NonNull String, @NonNull Object> parameters = test.getTimeQuery();
        TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> response = provider.fetchTree(parameters, PROGRESS_MONITOR);
        assertEquals(ITmfResponse.Status.COMPLETED, response.getStatus());
        TmfTreeModel<@NonNull TmfTreeDataModel> model = response.getModel();
        assertNotNull(model);
        parameters = test.getTimeQueryForModel(model);
        TmfModelResponse<@NonNull ITmfXyModel> yResponse = provider.fetchXY(parameters, PROGRESS_MONITOR);
        assertEquals(ITmfResponse.Status.COMPLETED, yResponse.getStatus());
        ITmfXyModel yModel = yResponse.getModel();
        assertNotNull(yModel);
        Collection<@NonNull ISeriesModel> data = yModel.getSeriesData();
        assertEquals(1, data.size());
        ISeriesModel ySeries = data.iterator().next();
        double[] expected = test.getActivity();
        double[] actual = ySeries.getData();
        for (int i = 0; i < expected.length; i++) {
            assertTrue(String.format("No actual value at position %d for %s", i, test), actual.length > i);
            assertEquals(String.format("Value at position %d for %s", i, test), expected[i], actual[i], 0.001);
        }
        assertEquals(String.format("More values than expected for %s", test), expected.length, actual.length);
    }
}
Also used : ISeriesModel(org.eclipse.tracecompass.tmf.core.model.xy.ISeriesModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) DisksIODataProvider(org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.DisksIODataProvider) DiskActivity(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.inputoutput.IoTestCase.DiskActivity) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ITmfXyModel(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel) Test(org.junit.Test)

Example 2 with TmfTreeModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.

the class CPUAnalysisBenchmark method benchmarkCPUModule.

@SuppressWarnings("restriction")
private static void benchmarkCPUModule(String testName, @NonNull LttngKernelTrace trace, int loopCount) throws TmfAnalysisException {
    Performance perf = Performance.getDefault();
    PerformanceMeter pmAnalysisExecution = perf.createPerformanceMeter(TEST_ID + testName + ": " + TEST_ANALYSIS_EXECUTION);
    perf.tagAsSummary(pmAnalysisExecution, TEST_ANALYSIS_EXECUTION + '(' + testName + ')', Dimension.CPU_TIME);
    PerformanceMeter pmQueryUsage = perf.createPerformanceMeter(TEST_ID + testName + ": " + TEST_ANALYSIS_QUERY);
    perf.tagAsSummary(pmQueryUsage, TEST_ANALYSIS_QUERY + '(' + testName + ')', Dimension.CPU_TIME);
    for (int i = 0; i < loopCount; i++) {
        KernelCpuUsageAnalysis module = getModule(trace);
        try {
            pmAnalysisExecution.start();
            TmfTestHelper.executeAnalysis(module);
            pmAnalysisExecution.stop();
            CpuUsageDataProvider dataProvider = CpuUsageDataProvider.create(trace);
            assertNotNull(dataProvider);
            // Query all CPU Usage for full time range, then 10 times 10%
            // smaller ranges
            int resolution = 1500;
            long startTime = trace.getStartTime().toNanos();
            long endTime = trace.getEndTime().toNanos();
            pmQueryUsage.start();
            for (int j = 0; j < 10; j++) {
                // Query the tree for that range
                TimeQueryFilter filter = new SelectedCpuQueryFilter(startTime, endTime, 2, Collections.emptyList(), Collections.emptySet());
                @NonNull Map<@NonNull String, @NonNull Object> parameters = new HashMap<>();
                parameters.put(DataProviderParameterUtils.REQUESTED_TIME_KEY, getTimeRequested(filter));
                parameters.put(DataProviderParameterUtils.REQUESTED_ITEMS_KEY, Collections.emptyList());
                parameters.put("cpus", Collections.emptySet());
                TmfModelResponse<@NonNull TmfTreeModel<@NonNull CpuUsageEntryModel>> response = dataProvider.fetchTree(parameters, NULL_MONITOR);
                TmfTreeModel<@NonNull CpuUsageEntryModel> model = response.getModel();
                assertNotNull(model);
                List<CpuUsageEntryModel> entries = model.getEntries();
                assertNotNull(entries);
                // Add all entries to the list of selected
                List<Long> selected = new ArrayList<>();
                for (CpuUsageEntryModel entry : entries) {
                    selected.add(entry.getId());
                }
                // Get the usage for all threads
                filter = new SelectedCpuQueryFilter(startTime, endTime, resolution, selected, Collections.emptySet());
                parameters = new HashMap<>();
                parameters.put(DataProviderParameterUtils.REQUESTED_TIME_KEY, getTimeRequested(filter));
                parameters.put(DataProviderParameterUtils.REQUESTED_ITEMS_KEY, selected);
                parameters.put("cpus", Collections.emptySet());
                TmfModelResponse<@NonNull ITmfXyModel> fetchXY = dataProvider.fetchXY(parameters, NULL_MONITOR);
                ITmfXyModel model2 = fetchXY.getModel();
                assertNotNull(model2);
                // Reduce the time range
                long step = (endTime - startTime) / 20;
                startTime += step;
                endTime -= step;
            }
            pmQueryUsage.stop();
        } finally {
            module.dispose();
        }
    }
    pmAnalysisExecution.commit();
    pmQueryUsage.commit();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KernelCpuUsageAnalysis(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis) SelectedCpuQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectedCpuQueryFilter) CpuUsageDataProvider(org.eclipse.tracecompass.internal.analysis.os.linux.core.cpuusage.CpuUsageDataProvider) NonNull(org.eclipse.jdt.annotation.NonNull) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) Performance(org.eclipse.test.performance.Performance) CpuUsageEntryModel(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.CpuUsageEntryModel) ITmfXyModel(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)

Example 3 with TmfTreeModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.

the class XmlXyDataProviderTest method assertAndGetTree.

private static Map<Long, String> assertAndGetTree(ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> xyProvider, ITmfTrace trace, List<String> expectedStrings) {
    TmfModelResponse<@NonNull TmfTreeModel<@NonNull ITmfTreeDataModel>> treeResponse = xyProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, Long.MAX_VALUE, 2)), MONITOR);
    assertNotNull(treeResponse);
    assertEquals(ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
    TmfTreeModel<@NonNull ITmfTreeDataModel> treeModel = treeResponse.getModel();
    assertNotNull(treeModel);
    List<@NonNull ITmfTreeDataModel> treeEntries = treeModel.getEntries();
    Map<Long, String> map = new HashMap<>();
    for (int i = 0; i < expectedStrings.size(); i++) {
        String expectedString = expectedStrings.get(i);
        assertTrue("actual entry absent at " + i + ": " + expectedString, treeEntries.size() > i);
        String[] split = expectedString.split(",");
        ITmfTreeDataModel xmlXyEntry = treeEntries.get(i);
        assertEquals("Checking entry name at " + i, split[0], xmlXyEntry.getName());
        // Check the parent
        long parentId = xmlXyEntry.getParentId();
        if (parentId < 0) {
            assertEquals("Checking empty parent at " + i, split[1], "null");
        } else {
            String parentName = map.get(parentId);
            assertEquals("Checking parent at " + i, split[1], parentName);
        }
        map.put(xmlXyEntry.getId(), xmlXyEntry.getName());
    }
    assertEquals("Extra actual entries", expectedStrings.size(), treeEntries.size());
    return map;
}
Also used : HashMap(java.util.HashMap) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)

Example 4 with TmfTreeModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.

the class TmfTreeDataModelTest method testCompositeTree.

/**
 * Test {@link TmfTreeCompositeDataProvider}
 */
@Test
public void testCompositeTree() {
    List<DummyDataProvider> ddps = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        ddps.add(new DummyDataProvider(i));
    }
    TmfTreeCompositeDataProvider<@NonNull TmfTreeDataModel, @NonNull DummyDataProvider> composite = new TmfTreeCompositeDataProvider<>(ddps, "composite-dummy");
    assertNotNull(composite);
    NullProgressMonitor monitor = new NullProgressMonitor();
    TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> tree = composite.fetchTree(Collections.emptyMap(), monitor);
    TmfTreeModel<@NonNull TmfTreeDataModel> model = tree.getModel();
    assertNotNull(model);
    assertEquals(Arrays.asList("header"), model.getHeaders());
    assertEquals(3, model.getEntries().size());
    // AnnotationCategories
    TmfModelResponse<@NonNull AnnotationCategoriesModel> returnVal = composite.fetchAnnotationCategories(Collections.emptyMap(), monitor);
    AnnotationCategoriesModel categoryModel = returnVal.getModel();
    assertNotNull(categoryModel);
    assertEquals(Arrays.asList("common", "0", "1", "2"), categoryModel.getAnnotationCategories());
    // Annotations
    TmfModelResponse<@NonNull AnnotationModel> annotations = composite.fetchAnnotations(Collections.emptyMap(), monitor);
    AnnotationModel annotationsModel = annotations.getModel();
    assertNotNull(annotationsModel);
    Collection<@NonNull Annotation> collection = annotationsModel.getAnnotations().get("test");
    assertNotNull(collection);
    assertEquals(6, collection.size());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) AnnotationCategoriesModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationCategoriesModel) ArrayList(java.util.ArrayList) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) NonNull(org.eclipse.jdt.annotation.NonNull) AnnotationModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfTreeCompositeDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.tree.TmfTreeCompositeDataProvider) Test(org.junit.Test)

Example 5 with TmfTreeModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.

the class HistogramDataProvider method fetchTree.

@Override
public TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    if (fCached != null) {
        return fCached;
    }
    fModule.waitForInitialization();
    Builder<TmfTreeDataModel> builder = ImmutableList.builder();
    builder.add(new TmfTreeDataModel(fTraceId, -1, Collections.singletonList(getTrace().getName())));
    builder.add(new TmfTreeDataModel(fTotalId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Total))));
    ITmfStateSystem eventsSs = Objects.requireNonNull(fModule.getStateSystem(TmfStatisticsEventTypesModule.ID));
    if (eventsSs.optQuarkAbsolute(Attributes.LOST_EVENTS) != ITmfStateSystem.INVALID_ATTRIBUTE) {
        builder.add(new TmfTreeDataModel(fLostId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Lost))));
    }
    if (eventsSs.waitUntilBuilt(0)) {
        TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> response = new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), builder.build()), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
        fCached = response;
        return response;
    }
    return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), builder.build()), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}
Also used : TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Aggregations

TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)34 NonNull (org.eclipse.jdt.annotation.NonNull)19 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)14 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)10 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)10 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)9 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)9 TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)8 Test (org.junit.Test)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)6 SegmentStoreStatisticsModel (org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel)5 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)5 ImmutableList (com.google.common.collect.ImmutableList)4 Nullable (org.eclipse.jdt.annotation.Nullable)4 ITableColumnDescriptor (org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor)4 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)4 Collection (java.util.Collection)3