当前位置: 首页>>代码示例>>Java>>正文


Java TimeUnit.NANOSECONDS属性代码示例

本文整理汇总了Java中java.util.concurrent.TimeUnit.NANOSECONDS属性的典型用法代码示例。如果您正苦于以下问题:Java TimeUnit.NANOSECONDS属性的具体用法?Java TimeUnit.NANOSECONDS怎么用?Java TimeUnit.NANOSECONDS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.util.concurrent.TimeUnit的用法示例。


在下文中一共展示了TimeUnit.NANOSECONDS属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        iter.reset(testJSON);
        bh.consume(iter.read(typeLiteral));
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:9,代码来源:DeserJsoniter.java

示例2:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        byteArrayOutputStream.reset();
        SerializeWriter writer = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(writer, serializeConfig);
        serializer.write(testObject);
        writer.writeToEx(byteArrayOutputStream, IOUtils.UTF8);
        serializer.close();
        bh.consume(byteArrayOutputStream);
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:14,代码来源:SerFastjson.java

示例3:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        bh.consume(Pb.PbTestObject.parseFrom(testData));
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:8,代码来源:DeserPb.java

示例4:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ser(Blackhole bh) throws TException {
    for (int i = 0; i < 1000; i++) {
        byteArrayOutputStream.reset();
        testObject.write(protocol);
        bh.consume(byteArrayOutputStream);
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:10,代码来源:SerThrift.java

示例5:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        byteArrayOutputStream.reset();
        objectMapper.writeValue(byteArrayOutputStream, testObject);
        bh.consume(byteArrayOutputStream);
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:10,代码来源:SerJackson.java

示例6: parserAndtoStringTest

@Test
public void parserAndtoStringTest(){
	Duration duration = new Duration(3, TimeUnit.DAYS);
	AssertJUnit.assertEquals("3d", duration.toString());
	duration = new Duration("1d2h65m15s");
	AssertJUnit.assertEquals("1d3h5m15s", duration.toString());
	duration = new Duration("2h1d65m15s");
	AssertJUnit.assertEquals("1d3h5m15s", duration.toString());
	duration = new Duration("15s");
	AssertJUnit.assertEquals(15, duration.toSecond());
	AssertJUnit.assertEquals("15s", duration.toString());
	duration = new Duration("100000d5s123ms");
	AssertJUnit.assertEquals("100000d5s123ms", duration.toString());
	duration = new Duration("100000 d 5s 123 ms");
	AssertJUnit.assertEquals("100000d5s123ms", duration.toString());
	duration = new Duration("48h");
	AssertJUnit.assertEquals("2d", duration.toString());
	duration = new Duration("0");
	AssertJUnit.assertEquals("0ms", duration.toString());
	duration = new Duration("max");
	AssertJUnit.assertEquals(MAX_VALUE.toString(TimeUnit.NANOSECONDS), duration.toString(TimeUnit.NANOSECONDS));
	duration = new Duration("1d1d");
	AssertJUnit.assertEquals("2d", duration.toString());
	duration = new Duration("4ms1us");
	AssertJUnit.assertEquals("4ms1us", duration.toString(TimeUnit.MICROSECONDS));
	duration = new Duration(1234, TimeUnit.NANOSECONDS);
	AssertJUnit.assertEquals("1us", duration.toString(TimeUnit.MICROSECONDS));
	AssertJUnit.assertEquals("1us", duration.toString(TimeUnit.NANOSECONDS));
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:29,代码来源:Duration.java

示例7:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        reader.reset();
        reader.read();
        reader.getNextToken();
        TestObject obj = new TestObject();
        ExternalSerialization.deserialize(obj, reader);
        bh.consume(obj);
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:13,代码来源:DeserDslJson.java

示例8:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        bh.consume(objectMapper.readValue(testJSON, typeReference));
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:8,代码来源:DeserJackson.java

示例9: load

private V load(K key) {
  if (entryLoader == null && expiringEntryLoader == null)
    return null;

  writeLock.lock();
  try {
    // Double check for entry
    ExpiringEntry<K, V> entry = getEntry(key);
    if (entry != null)
      return entry.getValue();

    if (entryLoader != null) {
      V value = entryLoader.load(key);
      put(key, value);
      return value;
    } else {
      ExpiringValue<? extends V> expiringValue = expiringEntryLoader.load(key);
      if (expiringValue == null) {
        put(key, null);
        return null;
      } else {
        long duration = expiringValue.getTimeUnit() == null ? expirationNanos.get() : expiringValue.getDuration();
        TimeUnit timeUnit = expiringValue.getTimeUnit() == null ? TimeUnit.NANOSECONDS : expiringValue.getTimeUnit();
        put(key, expiringValue.getValue(), expiringValue.getExpirationPolicy() == null ? expirationPolicy.get()
            : expiringValue.getExpirationPolicy(), duration, timeUnit);
        return expiringValue.getValue();
      }
    }
  } finally {
    writeLock.unlock();
  }
}
 
开发者ID:ProtocolSupport,项目名称:ProtocolSupportPocketStuff,代码行数:32,代码来源:ExpiringMap.java

示例10:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        byteArrayOutputStream.reset();
        testObject.writeTo(byteArrayOutputStream);
        bh.consume(byteArrayOutputStream);
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:10,代码来源:SerPb.java

示例11:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        bh.consume(Pb.PbTestReadObject.parseFrom(testData));
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:8,代码来源:DeserPb.java

示例12:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws TException {
    for (int i = 0; i < 1000; i++) {
        ThriftTestObject obj = new ThriftTestObject();
        deserializer.deserialize(testObject, testData);
        bh.consume(obj);
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:10,代码来源:DeserThrift.java

示例13:

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws IOException {
    for (int i = 0; i < 1000; i++) {
        bh.consume(PbTestObect.PbTestObject.parseFrom(testData));
    }
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:8,代码来源:DeserPb.java

示例14: NameableExecutor

public NameableExecutor(String name, int size, BlockingQueue<Runnable> queue, ThreadFactory factory) {
    super(size, size, Long.MAX_VALUE, TimeUnit.NANOSECONDS, queue, factory);
    this.name = name;
}
 
开发者ID:variflight,项目名称:feeyo-redisproxy,代码行数:4,代码来源:NameableExecutor.java


注:本文中的java.util.concurrent.TimeUnit.NANOSECONDS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。