本文整理汇总了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));
}
}
示例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);
}
}
示例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));
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
示例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);
}
}
示例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));
}
}
示例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();
}
}
示例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);
}
}
示例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));
}
}
示例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);
}
}
示例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));
}
}
示例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;
}