public void commit() { runs++; if (runs > warmUpRuns) { Log.d(TAG, "Writing results for run " + runs); String[] collectedHeaders = getAllFirsts(values); if (!Arrays.equals(collectedHeaders, headers)) { headers = collectedHeaders; String line = StringUtils.join(headers, "" + separator) + '\n'; try { FileUtils.appendUtf8(file, line); } catch (IOException e) { throw new RuntimeException("Could not write header in benchmark file", e); } } StringBuilder line = new StringBuilder(); for (Pair<String, String> pair : values) { line.append(pair.second).append(separator); } line.append('\n'); try { FileUtils.appendUtf8(file, line); } catch (IOException e) { throw new RuntimeException("Could not write header in benchmark file", e); } } else { Log.d(TAG, "Ignoring results for run " + runs + " (warm up)"); } values.clear(); }
@Test public void testConcatLines() { String[] lines = StringUtils.splitLines(LINES, false); ArrayList<String> list = new ArrayList<String>(); for (String line : lines) { list.add(line); } String concated = StringUtils.join(list, "\n"); assertEquals("Line 1\nLine 2\n\nLine 4\nLine 5\n\nLine 7", concated); }
public void commit() { runs++; if (runs > warmUpRuns) { Log.d(TAG, "Writing results for run " + runs); String[] collectedHeaders = getAllFirsts(values); if (!Arrays.equals(collectedHeaders, headers)) { headers = collectedHeaders; String line = StringUtils.join(headers, "" + separator) + '\n'; try { FileUtils.appendUtf8(file, line); } catch (IOException e) { throw new RuntimeException("Could not write header in benchmark file", e); } } StringBuilder line = new StringBuilder(); for (Pair<String, String> pair : values) { line.append(pair.second).append(separator); } line.append('\n'); try { FileUtils.appendUtf8(file, line); } catch (IOException e) { throw new RuntimeException("Could not write header in benchmark file", e); } } else { Log.d(TAG, "Ignoring results for run " + runs + " (warm up)"); } values.clear(); }