100101102103104105106107108109110
for (int i = 0; i < times; i++) { @SuppressWarnings("unused") String temp = base + i; } b.mark("after " + times); b.done(); } @Test public void testStringBufferAppend2() { StringBuffer buf = new StringBuffer(base);
113114115116117118119120121122123
b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done(); } @Test public void testStringBuilderAppend2() { StringBuilder buf = new StringBuilder(base);
126127128129130131132133134135136
b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done(); } @Test public void testStringFormat2() { String format = "%s%d";
6970717273747576
Assert.assertEquals(2916, histo.get("ConnectException")); Assert.assertEquals(230663, histo.get("Lost tracker")); Assert.assertEquals(166834, histo.get("mapred.TaskTracker: Resending")); b.done(); } }
8586878889909192939495
b.mark("thrift sink to thrift source done"); tes.close(); snk.close(); drain.interrupt(); b.done(); } /** * This is slighlty different by using another thread to kick off the sink. It * shouldn't really matter much.
153154155156157158159160161162163
Thread.sleep(1000); tes.close(); snk.close(); t.interrupt(); drain.interrupt(); b.done(); } /** * Here we are using the ThriftRawEventSink instead of the ThriftEventSink *
210211212213214215216217218
b.mark("thrift sink to thrift source done"); tes.close(); snk.close(); drain.interrupt(); b.done(); } }
7374757677787980818283
b.mark("reservoir", sz); res.close(); b.mark("count", cnt.getCount()); } b.done(); } @Test public void testIntervalSampler() throws IOException, InterruptedException { Benchmark b = new Benchmark("Interval sampler + nullsink");
114115116117118119120121122123124
b.mark("interval", sz); res.close(); b.mark("count", cnt.getCount()); } b.done(); } @Test public void testProbabilitySampler() throws IOException, InterruptedException { Benchmark b = new Benchmark("Reservoir sampler + nullsink");
156157158159160161162163164
b.mark("probability", prob); res.close(); b.mark("count", cnt.getCount()); } b.done(); } }