Examples of Benchmark


Examples of com.cloudera.util.Benchmark

  }

  @Test
  public void testStringAppend2() {
    Benchmark b = new Benchmark("String Append");

    b.mark("begin");
    for (int i = 0; i < times; i++) {
      @SuppressWarnings("unused")
      String temp = base + i;
    }
    b.mark("after " + times);
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

  }

  @Test
  public void testStringBufferAppend2() {
    StringBuffer buf = new StringBuffer(base);
    Benchmark b = new Benchmark("StringBuffer Append");

    b.mark("begin");
    for (int i = 0; i < times; i++) {
      buf.append(i);
    }
    b.mark("after " + times);
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

*/
public class PerfGrepReportSinks implements ExamplePerfData {

  @Test
  public void testHadoopGrep() throws IOException, InterruptedException {
    Benchmark b = new Benchmark("hadoop_greps");
    b.mark("begin");

    MultiGrepReporterBuilder bld = new MultiGrepReporterBuilder(HADOOP_GREP);

    MultiGrepReporterSink<String> snk = bld.load().iterator().next();
    snk.open();
    b.mark("filters_loaded", new File(HADOOP_GREP).getName());

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);

    b.mark("disk_loaded");

    EventUtil.dumpAll(mem, snk);
    b.mark(snk.getName() + " done");

    Histogram<String> histo = snk.getHistogram();
    System.out.println(histo);
   
    // from grep | wc
    Assert.assertEquals(230659, histo.get("NullPointerException"));
    Assert.assertEquals(2916, histo.get("ConnectException"));
    Assert.assertEquals(230663, histo.get("Lost tracker"));
    Assert.assertEquals(166834, histo.get("mapred.TaskTracker: Resending"));
   
   
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

  }

  @Test
  public void testStringBuilderAppend2() {
    StringBuilder buf = new StringBuilder(base);
    Benchmark b = new Benchmark("StringBuffer Append");

    b.mark("begin");
    for (int i = 0; i < times; i++) {
      buf.append(i);
    }
    b.mark("after " + times);
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

  }

  @Test
  public void testStringFormat2() {
    String format = "%s%d";
    Benchmark b = new Benchmark("StringFormatAppend");

    b.mark("begin");
    for (int i = 0; i < times; i++) {
      String.format(format, base, i);
    }
    b.mark("after " + times);
    b.done();

  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

   * @throws InterruptedException
   */
  @Test
  public void testThriftSend() throws IOException, InterruptedException {

    Benchmark b = new Benchmark("nullsink");

    b.mark("begin");

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();
    b.mark("disk_loaded");

    FlumeConfiguration conf = FlumeConfiguration.get();
    final ThriftEventSource tes = new ThriftEventSource(conf.getCollectorPort());
    tes.open();
    // need to drain the sink otherwise its queue will fill up with events!
    Thread drain = new Thread("drain") {
      public void run() {
        try {
          EventUtil.dumpAll(tes, new NullSink());
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    };
    drain.start(); // drain the sink.
    b.mark("receiver_started");

    final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
        .getCollectorPort());
    snk.open();
    b.mark("sink_started");

    EventUtil.dumpAll(mem, snk);
    b.mark("thrift sink to thrift source done");

    tes.close();
    snk.close();
    drain.interrupt();
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

   * mem -> ThriftEventSink -> ThriftEventSource -> NullSink
   **/
  @Test
  public void testThriftSendMulti() throws IOException, InterruptedException {

    Benchmark b = new Benchmark("nullsink");
    b.mark("begin");

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();
    b.mark("disk_loaded");

    FlumeConfiguration conf = FlumeConfiguration.get();
    final ThriftEventSource tes = new ThriftEventSource(conf.getCollectorPort());
    tes.open();
    // need to drain the sink otherwise its queue will fill up with events!
    Thread drain = new Thread("drain") {
      public void run() {
        try {
          EventUtil.dumpAll(tes, new NullSink());
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    };
    drain.start(); // drain the sink.
    b.mark("receiver_started");

    final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
        .getCollectorPort());

    Thread t = new Thread() {
      public void run() {
        try {
          snk.open();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    };
    t.start();
    b.mark("sink_started");

    EventUtil.dumpAll(mem, snk);
    b.mark("thrift sink to thrift source done");

    Thread.sleep(1000);
    tes.close();
    snk.close();
    t.interrupt();
    drain.interrupt();
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

   * @throws InterruptedException
   */
  @Test
  public void testThriftRawSend() throws IOException, InterruptedException {

    Benchmark b = new Benchmark("nullsink");

    b.mark("begin");

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();
    b.mark("disk_loaded");

    FlumeConfiguration conf = FlumeConfiguration.get();
    final ThriftEventSource tes = new ThriftEventSource(conf.getCollectorPort());
    tes.open();
    // need to drain the sink otherwise its queue will fill up with events!
    Thread drain = new Thread("drain") {
      public void run() {
        try {
          EventUtil.dumpAll(tes, new NullSink());
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    };
    drain.start(); // drain the sink.
    b.mark("receiver_started");

    final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
        .getCollectorPort());
    snk.open();
    b.mark("sink_started");

    EventUtil.dumpAll(mem, snk);
    b.mark("thrift sink to thrift source done");

    tes.close();
    snk.close();
    drain.interrupt();
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

*/
public class PerfSamplers implements ExamplePerfData {

  @Test
  public void testReservoirSampler() throws IOException, InterruptedException {
    Benchmark b = new Benchmark("Reservoir sampler + nullsink");
    b.mark("begin");
    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    b.mark("disk_loaded");

    NullSink nullsnk = new NullSink();
    EventUtil.dumpAll(mem, nullsnk);
    b.mark("warmup");

    int res_size[] = { 100, 1000, 10000, 100000 };
    for (int i = 0; i < res_size.length; i++) {
      mem.open();
      int sz = res_size[i];
      EventSink res = new ReservoirSamplerDeco<NullSink>(new NullSink(), sz);
      EventUtil.dumpAll(mem, res);
      b.mark("reservoir " + sz + " sampling done", sz);

      res.close();
      b.mark("sample dump done");
    }

    for (int i = 0; i < res_size.length; i++) {
      mem.open();
      int sz = res_size[i];
      CounterSink cnt = new CounterSink("null");
      EventSink res = new ReservoirSamplerDeco<CounterSink>(cnt, sz);
      EventUtil.dumpAll(mem, res);
      b.mark("reservoir", sz);

      res.close();
      b.mark("count", cnt.getCount());
    }
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

    b.done();
  }

  @Test
  public void testIntervalSampler() throws IOException, InterruptedException {
    Benchmark b = new Benchmark("Interval sampler + nullsink");
    b.mark("begin");
    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    b.mark("disk_loaded");

    NullSink nullsnk = new NullSink();
    EventUtil.dumpAll(mem, nullsnk);
    b.mark("warmup");

    int interval_size[] = { 100000, 10000, 1000, 100 };
    for (int i = 0; i < interval_size.length; i++) {
      mem.open();
      int sz = interval_size[i];
      EventSink res = new IntervalSampler<NullSink>(new NullSink(), sz);
      EventUtil.dumpAll(mem, res);
      b.mark("interval " + sz + " sampling done", sz);

      res.close();
      b.mark("sample dump done");
    }

    for (int i = 0; i < interval_size.length; i++) {
      mem.open();
      int sz = interval_size[i];
      CounterSink cnt = new CounterSink("null");
      EventSink res = new IntervalSampler<CounterSink>(cnt, sz);
      EventUtil.dumpAll(mem, res);
      b.mark("interval", sz);

      res.close();
      b.mark("count", cnt.getCount());
    }
    b.done();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.