changeset 1005:76d7ea927d5d

7901030: -prof perf fails with NumberFormatException on some locales
author shade
date Wed, 10 Sep 2014 18:59:26 +0400
parents 9a66e03cd539
children 2e7682a5da28
files jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java	Wed Sep 10 17:17:09 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java	Wed Sep 10 18:59:26 2014 +0400
@@ -37,6 +37,8 @@
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.text.NumberFormat;
+import java.text.ParseException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -137,12 +139,20 @@
 
                 Matcher m = Pattern.compile("(.*)#(.*)").matcher(line);
                 if (m.matches()) {
-                    String pair = m.group(1).replace(",", "").trim();
+                    String pair = m.group(1).trim();
                     if (pair.contains(" cycles")) {
-                        cycles = Long.valueOf(pair.split("[ ]+")[0]);
+                        try {
+                            cycles = NumberFormat.getInstance().parse(pair.split("[ ]+")[0]).longValue();
+                        } catch (ParseException e) {
+                            // do nothing, processing code will handle
+                        }
                     }
                     if (line.contains(" instructions")) {
-                        insns = Long.valueOf(pair.split("[ ]+")[0]);
+                        try {
+                            insns = NumberFormat.getInstance().parse(pair.split("[ ]+")[0]).longValue();
+                        } catch (ParseException e) {
+                            // do nothing, processing code will handle
+                        }
                     }
                 }
             }