From cbe563502b76f66a0862b9b6730eeda808047327 Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Mon, 5 Mar 2012 18:25:34 -0800 Subject: [PATCH 1/2] PerformanceEvaluation fixes. --- .../apache/hadoop/hbase/PerformanceEvaluation.java | 37 +++++++++++-------- 1 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java b/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java index 4b125d7..0aee6ad 100644 --- a/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java +++ b/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java @@ -500,14 +500,15 @@ public class PerformanceEvaluation { */ private void doMultipleClients(final Class cmd) throws IOException { final List threads = new ArrayList(this.N); + final long[] timings = new long[this.N]; final int perClientRows = R/N; for (int i = 0; i < this.N; i++) { - Thread t = new Thread (Integer.toString(i)) { + final int index = i; + Thread t = new Thread ("TestClient-" + i) { @Override public void run() { super.run(); PerformanceEvaluation pe = new PerformanceEvaluation(conf); - int index = Integer.parseInt(getName()); try { long elapsedTime = pe.runOneClient(cmd, index * perClientRows, perClientRows, R, @@ -516,6 +517,7 @@ public class PerformanceEvaluation { LOG.info("client-" + getName() + " " + msg); } }); + timings[index] = elapsedTime; LOG.info("Finished " + getName() + " in " + elapsedTime + "ms writing " + perClientRows + " rows"); } catch (IOException e) { @@ -537,6 +539,18 @@ public class PerformanceEvaluation { } } } + final String test = cmd.getSimpleName(); + LOG.info("[" + test + "] Summary of timings (ms): " + + Arrays.toString(timings)); + Arrays.sort(timings); + long total = 0; + for (int i = 0; i < this.N; i++) { + total += timings[i]; + } + LOG.info("[" + test + "]" + + "\tMin: " + timings[0] + "ms" + + "\tMax: " + timings[this.N - 1] + "ms" + + "\tAvg: " + (total / this.N) + "ms"); } /* @@ -716,7 +730,6 @@ public class PerformanceEvaluation { protected final int totalRows; private final Status status; protected byte[] tableName; - protected HBaseAdmin admin; protected HTable table; protected volatile Configuration conf; protected boolean flushCommits; @@ -749,13 +762,12 @@ public class PerformanceEvaluation { } void testSetup() throws IOException { - this.admin = new HBaseAdmin(conf); this.table = new HTable(conf, tableName); this.table.setAutoFlush(false); this.table.setScannerCaching(30); } - void testTakedown() throws IOException { + void testTakedown() throws IOException { if (flushCommits) { this.table.flushCommits(); } @@ -767,16 +779,15 @@ public class PerformanceEvaluation { * @throws IOException */ long test() throws IOException { - long elapsedTime; testSetup(); - long startTime = System.currentTimeMillis(); + LOG.info("Timed test starting in thread " + Thread.currentThread().getName()); + final long startTime = System.nanoTime(); try { testTimed(); - elapsedTime = System.currentTimeMillis() - startTime; } finally { testTakedown(); } - return elapsedTime; + return (System.nanoTime() - startTime) / 1000000; } /** @@ -797,8 +808,7 @@ public class PerformanceEvaluation { * Test for individual row. * @param i Row index. */ - void testRow(final int i) throws IOException { - } + abstract void testRow(final int i) throws IOException; } @SuppressWarnings("unused") @@ -957,11 +967,6 @@ public class PerformanceEvaluation { } @Override - void testSetup() throws IOException { - super.testSetup(); - } - - @Override void testTakedown() throws IOException { if (this.testScanner != null) { this.testScanner.close(); -- 1.7.9.189.g1851f