Search in sources :

Example 1 with KernelCpuUsageAnalysis

use of org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis in project tracecompass by tracecompass.

the class CPUAnalysisBenchmark method getModule.

private static KernelCpuUsageAnalysis getModule(@NonNull LttngKernelTrace trace) throws TmfAnalysisException {
    KernelCpuUsageAnalysis module = new KernelCpuUsageAnalysis();
    try {
        /* Initialize the analysis module */
        module.setId("test");
        module.setTrace(trace);
        return module;
    } catch (TmfAnalysisException e) {
        module.dispose();
        throw e;
    }
}
Also used : TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) KernelCpuUsageAnalysis(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis)

Example 2 with KernelCpuUsageAnalysis

use of org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis 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 KernelCpuUsageAnalysis

use of org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis in project tracecompass by tracecompass.

the class CpuUsageDataProvider method create.

/**
 * Create an instance of {@link CpuUsageDataProvider}. Returns a null instance
 * if the analysis module is not found.
 *
 * @param trace
 *            A trace on which we are interested to fetch a model
 * @return A CpuUsageDataProvider instance. If analysis module is not found, it
 *         returns null
 */
@Nullable
public static CpuUsageDataProvider create(ITmfTrace trace) {
    KernelCpuUsageAnalysis module = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID);
    KernelAnalysisModule kernelAnalysisModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID);
    if (module != null && kernelAnalysisModule != null) {
        module.schedule();
        kernelAnalysisModule.schedule();
        return new CpuUsageDataProvider(trace, module, kernelAnalysisModule);
    }
    return null;
}
Also used : KernelCpuUsageAnalysis(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

KernelCpuUsageAnalysis (org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 Performance (org.eclipse.test.performance.Performance)1 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)1 CpuUsageEntryModel (org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.CpuUsageEntryModel)1 KernelAnalysisModule (org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule)1 CpuUsageDataProvider (org.eclipse.tracecompass.internal.analysis.os.linux.core.cpuusage.CpuUsageDataProvider)1 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)1 SelectedCpuQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectedCpuQueryFilter)1 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)1 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)1 ITmfXyModel (org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)1