com.vmware.xenon.common.Utils.getBuffer()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中com.vmware.xenon.common.Utils.getBuffer()方法的一些代码示例,展示了Utils.getBuffer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.getBuffer()方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:getBuffer

Utils.getBuffer介绍

[英]See KryoSerializers#getBuffer(int)
[中]参见KryoSerializers#getBuffer(int)

代码示例

代码示例来源:origin: vmware/xenon

private static ByteBuffer decompressGZip(ByteBuffer bb) throws Exception {
  GZIPInputStream zis = new GZIPInputStream(new ByteBufferInputStream(bb));
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  try {
    byte[] buffer = Utils.getBuffer(1024);
    int len;
    while ((len = zis.read(buffer)) > 0) {
      out.write(buffer, 0, len);
    }
  } finally {
    zis.close();
    out.close();
  }
  return ByteBuffer.wrap(out.toByteArray());
}

代码示例来源:origin: vmware/xenon

@Test
public void toBytes() {
  final int expectedByteCount = 115;
  int count = 100000;
  ServiceDocument s = buildCloneOrSerializationObject();
  int byteCount = 0;
  long start = System.nanoTime() / 1000;
  for (int i = 0; i < count; i++) {
    byte[] content = Utils.getBuffer(1024);
    byteCount = Utils.toBytes(s, content, 0);
    assertTrue(content != null);
    assertTrue(content.length >= expectedByteCount);
  }
  long end = System.nanoTime() / 1000;
  double thpt = end - start;
  thpt /= 1000000;
  thpt = count / thpt;
  Logger.getAnonymousLogger().info(
      String.format(
          "Binary serializations per second: %f, iterations: %d, byte count: %d",
          thpt, count, byteCount));
  this.testResults.getReport().lastValue(TestResults.KEY_THROUGHPUT, thpt);
}

代码示例来源:origin: com.vmware.xenon/xenon-common

@Test
public void toBytes() {
  final int expectedByteCount = 115;
  int count = 100000;
  ServiceDocument s = buildCloneOrSerializationObject();
  int byteCount = 0;
  long start = System.nanoTime() / 1000;
  for (int i = 0; i < count; i++) {
    byte[] content = Utils.getBuffer(1024);
    byteCount = Utils.toBytes(s, content, 0);
    assertTrue(content != null);
    assertTrue(content.length >= expectedByteCount);
  }
  long end = System.nanoTime() / 1000;
  double thpt = end - start;
  thpt /= 1000000;
  thpt = count / thpt;
  Logger.getAnonymousLogger().info(
      String.format(
          "Binary serializations per second: %f, iterations: %d, byte count: %d",
          thpt, count, byteCount));
  this.testResults.getReport().lastValue(TestResults.KEY_THROUGHPUT, thpt);
}

代码示例来源:origin: vmware/xenon

int byteCountToObjectDefault = Utils.toBytes(st, Utils.getBuffer(1024), 0);
Output outDocumentImplicitDefault = KryoSerializers.serializeAsDocument(st,
    1024);

代码示例来源:origin: com.vmware.xenon/xenon-common

int byteCountToObjectDefault = Utils.toBytes(st, Utils.getBuffer(1024), 0);
Output outDocumentImplicitDefault = KryoSerializers.serializeAsDocument(st,
    1024);

相关文章