Mercurial > hg > release > thermostat-1.6
changeset 2001:1f5dc3abcf16
Sort profiler results table by execution time
Backport of 4e6f50297303 from HEAD. PR3046
Reviewed-by: jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-June/019927.html
author | Alex Macdonald <almacdon@redhat.com> |
---|---|
date | Wed, 29 Jun 2016 15:01:50 -0400 |
parents | 59385cdc7d0d |
children | 8658e633a5a2 |
files | vm-profiler/client-swing/src/main/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileView.java vm-profiler/client-swing/src/test/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileViewTest.java |
diffstat | 2 files changed, 42 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/vm-profiler/client-swing/src/main/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileView.java Wed Jun 29 15:01:48 2016 -0400 +++ b/vm-profiler/client-swing/src/main/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileView.java Wed Jun 29 15:01:50 2016 -0400 @@ -63,6 +63,8 @@ import javax.swing.JTable; import javax.swing.JToggleButton; import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.SortOrder; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.WindowConstants; @@ -260,6 +262,10 @@ return super.getCellRenderer(row, column); } }; + List <RowSorter.SortKey> sortKeys = new ArrayList<>(); + sortKeys.add(new RowSorter.SortKey(COLUMN_METHOD_TIME, SortOrder.DESCENDING)); + profileTable.getRowSorter().setSortKeys(sortKeys); + profileTable.setName("METHOD_TABLE"); tabPane.addTab(translator.localize(LocaleResources.PROFILER_RESULTS_TABLE).getContents(),
--- a/vm-profiler/client-swing/src/test/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileViewTest.java Wed Jun 29 15:01:48 2016 -0400 +++ b/vm-profiler/client-swing/src/test/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileViewTest.java Wed Jun 29 15:01:50 2016 -0400 @@ -36,6 +36,7 @@ package com.redhat.thermostat.vm.profiler.client.swing.internal; +import com.redhat.thermostat.client.swing.components.ThermostatTable; import net.java.openjdk.cacio.ctc.junit.CacioFESTRunner; import static org.junit.Assert.assertEquals; @@ -67,6 +68,7 @@ import org.fest.swing.fixture.FrameFixture; import org.fest.swing.fixture.JLabelFixture; import org.fest.swing.fixture.JListFixture; +import org.fest.swing.fixture.JScrollPaneFixture; import org.fest.swing.fixture.JTableFixture; import org.fest.swing.fixture.JToggleButtonFixture; import org.junit.After; @@ -268,6 +270,40 @@ }); } + + @GUITest + @Test + public void testMethodsWithLargestExecutionTimeAppearFirst() throws InvocationTargetException, InterruptedException { + + frame.show(); + + final JScrollPaneFixture scrollPane = frame.scrollPane("METHOD_TABLE"); + + List<ProfilingResult.MethodInfo> data = new ArrayList<>(); + data.add(new ProfilingResult.MethodInfo(new MethodDescriptorConverter.MethodDeclaration( + "foo", Arrays.asList("int"), "int"), 10000, 70)); + data.add(new ProfilingResult.MethodInfo(new MethodDescriptorConverter.MethodDeclaration( + "bar", Arrays.asList("int"), "double"), 1000, 30)); + data.add(new ProfilingResult.MethodInfo(new MethodDescriptorConverter.MethodDeclaration( + "baz", Arrays.asList("double"), "double"), 100, 30)); + final ProfilingResult result = new ProfilingResult(data); + + view.setProfilingDetailData(result); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + TableModel model = + ((ThermostatTable) scrollPane.component().getViewport().getView()).getModel(); + assertEquals(3, model.getRowCount()); + + assertEquals("int foo(int)", model.getValueAt(0, 0).toString()); + assertEquals("double bar(int)", model.getValueAt(1, 0).toString()); + assertEquals("double baz(double)", model.getValueAt(2, 0).toString()); + } + }); + } + @GUITest @Test public void testSetProfilingDetailDataWithResults() throws InvocationTargetException,