Examples of Benchmark


Examples of com.cloudera.util.Benchmark

  String base = "this is a test";

  @Test
  public void testStringToByteArray() {
    Benchmark b = new Benchmark("String to ByteArray");

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

Examples of com.cloudera.util.Benchmark

    b.done();
  }

  @Test
  public void testStringToWrapByteBuffer() {
    Benchmark b = new Benchmark("String wrap ByteBuf");

    b.mark("begin");
    for (int i = 0; i < times; i++) {
      ByteBuffer.wrap(base.getBytes());
    }
    b.mark("after " + times);
    b.done();

  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

  }

  @Test
  public void testStringtoByteBufferCopy() {
    Benchmark b = new Benchmark("String alloc ByteBuf");

    b.mark("begin");
    for (int i = 0; i < times; i++) {
      byte[] buf = base.getBytes();
      ByteBuffer bb = ByteBuffer.allocate(buf.length);
      bb.put(buf);
    }
    b.mark("after " + times);
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

    b.done();
  }

  @Test
  public void testStringToByteArray2() {
    Benchmark b = new Benchmark("String to ByteArray");

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

Examples of com.cloudera.util.Benchmark

    b.done();
  }

  @Test
  public void testStringToWrapByteBuffer2() {
    Benchmark b = new Benchmark("String wrap ByteBuf");

    b.mark("begin");
    for (int i = 0; i < times; i++) {
      ByteBuffer.wrap(base.getBytes());
    }
    b.mark("after " + times);
    b.done();

  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

  }

  @Test
  public void testStringtoByteBufferCopy2() {
    Benchmark b = new Benchmark("String alloc ByteBuf");

    b.mark("begin");
    for (int i = 0; i < times; i++) {
      byte[] buf = base.getBytes();
      ByteBuffer bb = ByteBuffer.allocate(buf.length);
      bb.put(buf);
    }
    b.mark("after " + times);
    b.done();
  }
View Full Code Here

Examples of com.cloudera.util.Benchmark

  String base = "this is a test";

  @Test
  public void testStringAppend() {
    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 testStringBufferAppend() {
    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

  }

  @Test
  public void testStringBuilderAppend() {
    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 testStringFormat() {
    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
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.