From 6b5cb857a606e215cbb6b2d02a72aec7e67bf806 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Tue, 19 Nov 2024 10:44:12 -0500 Subject: [PATCH] tmf.ui: Instrument Histogram Add two flow scope logs and one scope log. Change-Id: I1b59629da5f7f417880d8f35694fb296eaaddc62 Signed-off-by: Matthew Khouzam --- .../tmf/ui/views/histogram/Histogram.java | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java index aacc606509..6652409ffe 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java @@ -18,6 +18,9 @@ package org.eclipse.tracecompass.tmf.ui.views.histogram; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.layout.GridDataFactory; @@ -48,6 +51,9 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; +import org.eclipse.tracecompass.common.core.log.TraceCompassLog; +import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils; +import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog; import org.eclipse.tracecompass.internal.tmf.ui.views.histogram.HistogramTimeAdapter; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; @@ -110,6 +116,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi // ------------------------------------------------------------------------ private static final int TIME_SCALE_HEIGHT = 27; + private static final Logger LOGGER = TraceCompassLog.getLogger(Histogram.class); // Histogram colors @@ -250,7 +257,6 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi */ static boolean showTraces = true; - private boolean fSendTimeAlignSignals = false; private IStatusLineManager fStatusLineManager; @@ -655,17 +661,25 @@ protected void moveCursor(final int keyCode) { */ @Override public void modelUpdated() { - if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) { - fCanvas.getDisplay().asyncExec(() -> { - if (!fCanvas.isDisposed()) { - // Retrieve and normalize the data - final int canvasWidth = fCanvas.getBounds().width; - final int canvasHeight = fCanvas.getBounds().height; - if (canvasWidth <= 0 || canvasHeight <= 0) { - return; + try (TraceCompassLogUtils.FlowScopeLog fs = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:ModelUpdated").setCategory("Histogram").build()) { //$NON-NLS-1$ //$NON-NLS-2$ + if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) { + fCanvas.getDisplay().asyncExec(() -> { + int canvasWidth = -1; + int canvasHeight = -1; + try (TraceCompassLogUtils.FlowScopeLog fs1 = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:getbounds").setParentScope(fs).build()) { //$NON-NLS-1$ + if (!fCanvas.isDisposed()) { + // Retrieve and normalize the data + canvasWidth = fCanvas.getBounds().width; + canvasHeight = fCanvas.getBounds().height; } - fDataModel.setSelection(fSelectionBegin, fSelectionEnd); - fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1); + } + + if (canvasHeight <= 0 || canvasWidth <= 0) { + return; + } + fDataModel.setSelection(fSelectionBegin, fSelectionEnd); + fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1); + try (TraceCompassLogUtils.FlowScopeLog fs1 = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:ui").setParentScope(fs).build()) { //$NON-NLS-1$ synchronized (fDataModel) { if (fScaledData != null) { fCanvas.redraw(); @@ -679,16 +693,16 @@ public void modelUpdated() { GridData gd = (GridData) fMaxNbEventsLabel.getLayoutData(); gd.widthHint = Math.max(gd.widthHint, fMaxNbEventsLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); fMaxNbEventsLabel.getParent().layout(); - if (old.length() < fMaxNbEventsLabel.getText().length()) { - if ((fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) { - TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true)); - } + if (old.length() < fMaxNbEventsLabel.getText().length() && (fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) { + TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true)); } + } fTimeLineScale.redraw(); } - } - }); + } + }); + } } } @@ -786,7 +800,7 @@ private void formatImage(final GC imageGC, final Image image) { final HistogramScaledData scaledData = new HistogramScaledData(fScaledData); - try { + try (ScopeLog sl = new ScopeLog(LOGGER, Level.FINER, "Histogram:FmtImg")) { //$NON-NLS-1$ final int height = image.getBounds().height; // Clear the drawing area