Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Johnson2019-08-25 16:15:29 -0400
committerAndrew Johnson2019-08-25 16:15:29 -0400
commit4e556c1e0bdf5e4f6b09c964f2bc3d4773254457 (patch)
tree8d2f4d23026824836b1526b8ef28b2755a669051
parent2bee17237c07090b8a0ea5e0584fcb7c78407db2 (diff)
downloadorg.eclipse.mat-4e556c1e0bdf5e4f6b09c964f2bc3d4773254457.tar.gz
org.eclipse.mat-4e556c1e0bdf5e4f6b09c964f2bc3d4773254457.tar.xz
org.eclipse.mat-4e556c1e0bdf5e4f6b09c964f2bc3d4773254457.zip
277422: Nice if heap parsing was multi-threaded
Performance regression test CSV fixes Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=277422 Change-Id: I5be1f11e834a3c7e1b64df38f951849f183e0a18
-rw-r--r--plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/RegTestUtils.java7
-rw-r--r--plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestApplication.java47
-rw-r--r--plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestParseApp.java9
3 files changed, 45 insertions, 18 deletions
diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/RegTestUtils.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/RegTestUtils.java
index 0473cf17..e66bafcc 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/RegTestUtils.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/RegTestUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 SAP AG.
+ * Copyright (c) 2008, 2019 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* SAP AG - initial API and implementation
+ * Andrew Johnson - CSV changes
*******************************************************************************/
package org.eclipse.mat.tests.regression;
@@ -16,12 +17,14 @@ import java.io.FilenameFilter;
import java.util.List;
import java.util.regex.Pattern;
+import com.ibm.icu.text.DecimalFormatSymbols;
+
public class RegTestUtils
{
static final String BASELINE_EXTENSION = "_baseline";
static final String TEST_EXTENSION = "_test";
static final String RESULT_FILENAME = "result.xml";
- public static final String SEPARATOR = ";";
+ public static final String SEPARATOR = new DecimalFormatSymbols().getDecimalSeparator() == ',' ? ";" : ",";
private static FileFilter filter = new FileFilter()
{
diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestApplication.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestApplication.java
index 1233889f..a857f25c 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestApplication.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestApplication.java
@@ -487,6 +487,29 @@ public class TestApplication
}
+ /**
+ * Escape CSV fields according to RFC 4180.
+ * @param data
+ * @param sep separator e.g. comma, semicolon
+ * @return escaped data
+ */
+ private String escapeCSVField(String data, String sep)
+ {
+ boolean hasSeparator = data.indexOf(sep) >= 0;
+ boolean hasQuote = data.indexOf('"') >= 0;
+ boolean hasNewLine = data.indexOf('\n') >= 0 || data.indexOf('\r') >= 0 && data.indexOf('\f') >= 0;
+
+ if (hasSeparator || hasQuote || hasNewLine)
+ {
+ if (hasQuote)
+ {
+ data = data.replace("\"", "\"\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return "\"" + data + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return data;
+ }
+
private void generatePerformanceReport(List<TestSuiteResult> results) throws IOException
{
File report = new File(dumpDir, String.format("performanceResults_%1$tY%1$tm%1$td%1$tH%1$tM.csv", new Date()));
@@ -507,7 +530,7 @@ public class TestApplication
.append("Used memory").append(RegTestUtils.SEPARATOR) //
.append("Free memory").append(RegTestUtils.SEPARATOR) //
.append("Total memory").append(RegTestUtils.SEPARATOR) //
- .append("Maximum memory").append(RegTestUtils.SEPARATOR) //
+ .append("Maximum memory") //
.append("\n");
Bundle bundle = Platform.getBundle("org.eclipse.mat.api");
@@ -522,17 +545,17 @@ public class TestApplication
for (PerfData record : result.getPerfData())
{
- out.append(relativePath).append(RegTestUtils.SEPARATOR) //
- .append(record.getTestName()).append(RegTestUtils.SEPARATOR) //
- .append(date).append(RegTestUtils.SEPARATOR) //
- .append(record.getTime()).append(RegTestUtils.SEPARATOR) //
- .append(buildId).append(RegTestUtils.SEPARATOR) //
- .append(result.getJVMflags()).append(RegTestUtils.SEPARATOR) //
- .append(record.getUsedMem()).append(RegTestUtils.SEPARATOR) //
- .append(record.getFreeMem()).append(RegTestUtils.SEPARATOR) //
- .append(record.getTotalMem()).append(RegTestUtils.SEPARATOR) //
- .append(record.getMaxMem()) //
- .append("\n");
+ out.append(escapeCSVField(relativePath, RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(record.getTestName(), RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(date, RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(record.getTime(), RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(buildId, RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(result.getJVMflags(), RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(record.getUsedMem(), RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(record.getFreeMem(), RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(record.getTotalMem(), RegTestUtils.SEPARATOR)).append(RegTestUtils.SEPARATOR) //
+ .append(escapeCSVField(record.getMaxMem(), RegTestUtils.SEPARATOR)) //
+ .append("\n");
}
}
diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestParseApp.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestParseApp.java
index 4cd0a60a..19fc2ebe 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestParseApp.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/regression/TestParseApp.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008,2019 SAP AG and IBM Corporation.
+ * Copyright (c) 2008, 2019 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* SAP AG - initial API and implementation
- * Andrew Johnson - Xmx and thread numbers
+ * Andrew Johnson (IBM Corporation) - Xmx and thread numbers
*******************************************************************************/
package org.eclipse.mat.tests.regression;
@@ -53,9 +53,10 @@ public class TestParseApp
finally
{
if (snapshot != null) SnapshotFactory.dispose(snapshot);
- }
- listener.done();
+ // If there was an error then this will still show the last message
+ listener.done();
+ }
}
private static class ClockedProgressListener implements IProgressListener

Back to the top