diff options
author | Jeremy Chang <jeremy.chang@linaro.org> | 2011-03-23 13:41:49 +0800 |
---|---|---|
committer | Jeremy Chang <jeremy.chang@linaro.org> | 2011-03-24 18:17:41 +0800 |
commit | 911eec1ad9c97db415b26a530372bdf8cf73beb3 (patch) | |
tree | d3e1f4fe99122b80a368a6dbcb86c8e755762989 | |
parent | 2e12a2fc223485efe7abdb6af836ad746057b5a9 (diff) | |
download | 0xbench-911eec1ad9c97db415b26a530372bdf8cf73beb3.tar.gz |
Enable the report of libMicro
The report will be presented as:
$Benchmark_Name <space> $Number <space> $Unit
The number is fetched from the number of the "mean of 95%" from stdout
and the unit is usecs/call while the uploaded result is still nsecs/call
as used to be.
-rw-r--r-- | src/org/opensolaris/hub/libmicro/NativeCaseMicro.java | 5 | ||||
-rw-r--r-- | src/org/opensolaris/hub/libmicro/NativeTesterMicro.java | 74 |
2 files changed, 68 insertions, 11 deletions
diff --git a/src/org/opensolaris/hub/libmicro/NativeCaseMicro.java b/src/org/opensolaris/hub/libmicro/NativeCaseMicro.java index ce5f307..d6c0190 100644 --- a/src/org/opensolaris/hub/libmicro/NativeCaseMicro.java +++ b/src/org/opensolaris/hub/libmicro/NativeCaseMicro.java @@ -1,4 +1,5 @@ /* + * Copyright 2011 Linaro Limited * Copyright (C) 2010 0xlab - http://0xlab.org/ * Authored by: Joseph Chang (bizkit) <bizkit@0xlab.org> * @@ -85,9 +86,7 @@ public class NativeCaseMicro extends Case { if (!couldFetchReport()) { return "No benchmark report"; } - - return ""; -// return mInfo[0].getString(NativeTesterMicro.REPORT); + return mInfo[0].getString(NativeTesterMicro.REPORT); } @Override diff --git a/src/org/opensolaris/hub/libmicro/NativeTesterMicro.java b/src/org/opensolaris/hub/libmicro/NativeTesterMicro.java index a49e6b6..6d14812 100644 --- a/src/org/opensolaris/hub/libmicro/NativeTesterMicro.java +++ b/src/org/opensolaris/hub/libmicro/NativeTesterMicro.java @@ -1,4 +1,5 @@ /* + * Copyright 2011 Linaro Limited * Copyright (C) 2010 0xlab - http://0xlab.org/ * Authored by: Joseph Chang (bizkit) <bizkit@0xlab.org> * @@ -29,6 +30,8 @@ import java.util.List; public class NativeTesterMicro extends NativeTester { + public final String TAG = "TesterLibMicro"; + private final double ERROR_VALUE = -1.0; public static final String REPORT = "REPORT"; public static final String RESULT = "RESULT"; private static final String Opts = "-E -C 70 -L -S -W"; @@ -387,19 +390,62 @@ public class NativeTesterMicro extends NativeTester { return COMMANDS; } + /* + * The unit is usecs/call + */ + private double getBenchResult(String command) { + String stdOut = mStdOuts.get(command); + int index = stdOut.lastIndexOf("mean of 95%"); + double value = 0.0; + try { + String summary = stdOut.substring(index, stdOut.length()); + String[] substrings = summary.toString().split("\\s+"); + value = Double.valueOf(substrings[3]); + return value; + } + catch (StringIndexOutOfBoundsException sioobe) { + Log.d(TAG, "StringIndexOutOfBoundsException"); + } + catch (ArrayIndexOutOfBoundsException aioobe) { + Log.d(TAG, "ArrayIndexOutOfBoundsException"); + } + catch (NumberFormatException nfe) { + Log.d(TAG, "NumberFormatException"); + } + return ERROR_VALUE; + } + + private String getCommandName(String command) { + if (command == null || command.equals("")) + return command; + String stdErr = mStdErrs.get(command); + + try { + String[] substrings = stdErr.split("\\s+"); + String commandName = substrings[1]; + return commandName; + } + catch (Exception ex) { + String[] substrings = command.toString().split("\\s+"); + return substrings[0]; + } + } + @Override protected boolean saveResult(Intent intent) { Bundle bundle = new Bundle(); -// StringBuilder report = new StringBuilder(); + StringBuilder report = new StringBuilder(); for (String command: getCommands()) { -// report.append(mStdErrs.get(command)); -// report.append("---------------------------\n"); -// report.append(mStdOuts.get(command)); -// report.append("---------------------------\n"); if(!mSockets.containsKey(command)) continue; String [] lines = mSockets.get(command).trim().split("\n"); String name = lines[0].trim().split("\t")[0]; + if (name.equals("")) { + report.append(getCommandName(command)); + } + else { + report.append(name); + } StringBuilder list = new StringBuilder();; for(String line: lines) { String [] sp = line.trim().split("\t"); @@ -417,11 +463,23 @@ public class NativeTesterMicro extends NativeTester { continue; } } - bundle.putString(command+"S", name); - bundle.putString(command+"FA", list.toString().trim()); + if(!mStdOuts.containsKey(command)) { + report.append("\n"); + continue; + } + + double value = getBenchResult(command); + if (value == ERROR_VALUE) { + report.append(" FAIL\n"); + } + else { + report.append(" " + value + " usecs/call\n"); + bundle.putString(command+"S", name); + bundle.putString(command+"FA", list.toString().trim()); + } } -// bundle.putString(REPORT, report.toString()); + bundle.putString(REPORT, report.toString()); intent.putExtra(RESULT, bundle); return true; } |