From 1f5f737c8bcf640edcc8db2b6d9827ecfdcedf04 Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Tue, 27 Mar 2012 11:54:35 -0400 Subject: [PATCH] Optimizing the GATKReportTable.write -- Better iteration, caching of strings, better printf calls, to improve the writing performance of GATKReportTables --- .../sting/gatk/report/GATKReportTable.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportTable.java b/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportTable.java index 62c36ca6c..e0e3ad1fc 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportTable.java +++ b/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportTable.java @@ -756,10 +756,6 @@ public class GATKReportTable { */ // Get the column widths for everything - HashMap columnFormats = new HashMap(); - for (String columnName : columns.keySet()) { - columnFormats.put(columnName, columns.get(columnName).getColumnFormat()); - } String primaryKeyFormat = "%-" + getPrimaryKeyColumnWidth() + "s"; // Emit the table definition @@ -787,7 +783,7 @@ public class GATKReportTable { if (needsPadding) { out.printf(" "); } - out.printf(columnFormats.get(columnName).getNameFormat(), columnName); + out.printf(columns.get(columnName).getColumnFormat().getNameFormat(), columnName); needsPadding = true; } @@ -796,29 +792,31 @@ public class GATKReportTable { out.printf("%n"); // Emit the table body - for (Object primaryKey : primaryKeyColumn) { + for (final Object primaryKey : primaryKeyColumn) { needsPadding = false; if (primaryKeyDisplay) { out.printf(primaryKeyFormat, primaryKey); needsPadding = true; } - for (String columnName : columns.keySet()) { - if (columns.get(columnName).isDisplayable()) { + for (final Map.Entry entry : columns.entrySet()) { + final GATKReportColumn column = entry.getValue(); + if (column.isDisplayable()) { if (needsPadding) { - out.printf(" "); + out.print(" "); } - String value = columns.get(columnName).getStringValue(primaryKey); - out.printf(columnFormats.get(columnName).getValueFormat(), value); + + final String value = column.getStringValue(primaryKey); + out.printf(column.getColumnFormat().getValueFormat(), value); needsPadding = true; } } - out.printf("%n"); + out.println(); } - out.printf("%n"); + out.println(); } public int getNumRows() {