Java Code Examples for java.util.concurrent.TimeUnit#MICROSECONDS
The following examples show how to use
java.util.concurrent.TimeUnit#MICROSECONDS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpectMaxExecutionTimeAnnotationFormatter.java From quickperf with Apache License 2.0 | 6 votes |
private TimeUnit findMaxUnitToDisplay(ExpectMaxExecutionTime annotation) { if(annotation.hours() != 0) { return TimeUnit.HOURS; } if(annotation.minutes() != 0) { return TimeUnit.MINUTES; } if(annotation.seconds() != 0) { return TimeUnit.SECONDS; } if(annotation.milliSeconds() != 0) { return TimeUnit.MILLISECONDS; } if(annotation.microSeconds() != 0) { return TimeUnit.MICROSECONDS; } if(annotation.nanoSeconds() != 0) { return TimeUnit.NANOSECONDS; } return TimeUnit.HOURS; }
Example 2
Source File: InfluxDbWriteObjectSerializerTest.java From dropwizard-metrics-influxdb with Apache License 2.0 | 6 votes |
@Test public void shouldOmitNaNsEtcWhenSerializingUsingLineProtocolForDouble() { Map<String, Object> fields = new LinkedHashMap<String, Object>(); fields.put("field1Key", "field1Value"); fields.put("field2Key", Double.NaN); fields.put("field3Key", Double.POSITIVE_INFINITY); fields.put("field4Key", Double.NEGATIVE_INFINITY); fields.put("field5Key", 0.432); InfluxDbWriteObject influxDbWriteObject = new InfluxDbWriteObject("test-db", TimeUnit.MICROSECONDS); influxDbWriteObject.getPoints().add(new InfluxDbPoint("measurement1", 456l, fields)); InfluxDbWriteObjectSerializer influxDbWriteObjectSerializer = new InfluxDbWriteObjectSerializer(""); String lineString = influxDbWriteObjectSerializer.getLineProtocolString(influxDbWriteObject); assertThat(lineString).isEqualTo("measurement1 field1Key=\"field1Value\",field5Key=0.432 456000\n"); }
Example 3
Source File: ArrayBenchmark.java From turbo-rpc with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public long loopReadLongDirectByteBuffer() { long value = 0; directByteBuffe.position(0); while (directByteBuffe.hasRemaining()) { value = directByteBuffe.getLong(); } return value; }
Example 4
Source File: AtomicIntergerArrayBenchmark.java From turbo-rpc with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public int sumByAtomicMuiltInteger1() { atomicMuiltInteger1.set(1, 1); return atomicMuiltInteger1.sum(); }
Example 5
Source File: GetBenchmark.java From Oak with Apache License 2.0 | 5 votes |
@Warmup(iterations = 5) @Measurement(iterations = 10) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Fork(value = 1) @Threads(8) @Benchmark public void get(Blackhole blackhole,BenchmarkState state,ThreadState threadState) { String key = state.keys.get(threadState.i++ % state.numRows); String val = state.oakMap.get(key); blackhole.consume(val); }
Example 6
Source File: InfluxDbWriteObjectSerializerTest.java From dropwizard-metrics-influxdb with Apache License 2.0 | 5 votes |
@Test public void shouldEscapeMeasurement() { Map<String, String> tags = new HashMap<String, String>(); Map<String, Object> fields = new HashMap<String, Object>(); fields.put("field1 Key", "field1Value"); InfluxDbWriteObject influxDbWriteObject = new InfluxDbWriteObject("test-db", TimeUnit.MICROSECONDS); influxDbWriteObject.getPoints().add(new InfluxDbPoint("my measurement,1=1", tags, 456l, fields)); InfluxDbWriteObjectSerializer influxDbWriteObjectSerializer = new InfluxDbWriteObjectSerializer(""); String lineString = influxDbWriteObjectSerializer.getLineProtocolString(influxDbWriteObject); assertThat(lineString) .isEqualTo("my\\ measurement\\,1=1 field1\\ Key=\"field1Value\" 456000\n"); }
Example 7
Source File: SvmSgdOnlineRunner.java From twister2 with Apache License 2.0 | 5 votes |
private BaseWindowedSink getWindowSinkInstance() { BaseWindowedSink baseWindowedSink = new IterativeStreamingWindowedCompute( new ProcessWindowFunctionImpl(), OperationMode.STREAMING, this.svmJobParameters, this.binaryBatchModel, "online-training-graph"); WindowArguments windowArguments = this.svmJobParameters.getWindowArguments(); TimeUnit timeUnit = TimeUnit.MICROSECONDS; if (windowArguments != null) { WindowType windowType = windowArguments.getWindowType(); if (windowArguments.isDuration()) { if (windowType.equals(WindowType.TUMBLING)) { baseWindowedSink .withTumblingDurationWindow(windowArguments.getWindowLength(), timeUnit); } if (windowType.equals(WindowType.SLIDING)) { baseWindowedSink .withSlidingDurationWindow(windowArguments.getWindowLength(), timeUnit, windowArguments.getSlidingLength(), timeUnit); } } else { if (windowType.equals(WindowType.TUMBLING)) { baseWindowedSink .withTumblingCountWindow(windowArguments.getWindowLength()); } if (windowType.equals(WindowType.SLIDING)) { baseWindowedSink .withSlidingCountWindow(windowArguments.getWindowLength(), windowArguments.getSlidingLength()); } } } return baseWindowedSink; }
Example 8
Source File: ConcurrentHashMapBenchmark.java From turbo-rpc with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public Integer nonBlockingHashMapLong() { int random = ThreadLocalRandom.current().nextInt(1024 * 256); nonBlockingHashMapLong.remove(random); nonBlockingHashMapLong.put(random, random); return nonBlockingHashMapLong.get(random); }
Example 9
Source File: ByteBufferBenchmark.java From turbo-rpc with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void writeByteToUnsafe() { for (int i = 0; i < 1024; i++) { UnsafeUtils.unsafe().putByte(OFFSET + i, (byte) 1); } }
Example 10
Source File: ResumableApiTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** Verify that tryResume(TransctionId, long, TimeUnit) waits the full time and returns the expected * value. * * @param txId The transaction ID to attempt to resume. * @param timeValue A tryResume argument. * @param unit A tryResume argument. * @param expectedResult The expected result from tryResume. */ private void verifyTryResumeWaits(TransactionId txId, long timeValue, TimeUnit unit, boolean expectedResult) { Object[] tmp = tryResume(txId, timeValue, unit); boolean result = (Boolean)tmp[0]; long duration = (Long)tmp[1]; // verify the wait long expectedWaitMs = timeValue; if (unit == TimeUnit.SECONDS) { expectedWaitMs = timeValue * 1000; } else if (unit == TimeUnit.MICROSECONDS) { expectedWaitMs = timeValue / 1000; } else if (unit == TimeUnit.NANOSECONDS) { expectedWaitMs = timeValue / 1000000; } else if (unit == TimeUnit.MILLISECONDS){ // already set } else { throw new TestException("Unknown TimeUnit " + unit); } if (duration < expectedWaitMs) { throw new TestException("Expected tryResume(" + txId + ", " + timeValue + ", " + unit + ") to wait for " + expectedWaitMs + "ms but it took " + duration + "ms"); } if (result != expectedResult) { throw new TestException("Expected tryResume(" + txId + ", " + timeValue + ", " + unit + ") to return " + expectedResult + ", but it returned " + result); } }
Example 11
Source File: AtomicIntergerArrayBenchmark.java From turbo-rpc with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public int sumByAtomicMuiltInteger2() { atomicMuiltInteger2.set(1, 1); return atomicMuiltInteger2.sum(); }
Example 12
Source File: BufferBenchmarkTest.java From java-cme-mdp3-handler with GNU Lesser General Public License v3.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Fork(1) @Warmup(iterations = 2, time = 3) @Measurement(iterations = 3, time = 7) public void test(){ buffer.add(n1); buffer.remove(); }
Example 13
Source File: JdbcAppenderBenchmark.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Benchmark public void testResponseTimeHSQLDBMessage(final Blackhole bh) { loggerHSQLDB.info("Test message"); }
Example 14
Source File: UUIDBenchmark.java From turbo-rpc with Apache License 2.0 | 4 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public Object newObject() throws Exception { return new Object(); }
Example 15
Source File: URLEncodeBenchmark.java From turbo-rpc with Apache License 2.0 | 4 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public String decodeByJavaURLEncoder() throws Exception { return URLDecoder.decode(encoded, "UTF-8"); }
Example 16
Source File: ExceptionBenchmark.java From turbo-rpc with Apache License 2.0 | 4 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public Object newObject() { return new Object(); }
Example 17
Source File: UUIDBenchmark.java From turbo-rpc with Apache License 2.0 | 4 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public RandomId128 newRandomId128() throws Exception { return RandomId128.next(); }
Example 18
Source File: ConcurrentArrayListBenchmark.java From turbo-rpc with Apache License 2.0 | 4 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public Boolean getByCopyOnWriteArrayList() { return copyOnWriteArrayList.get(512); }
Example 19
Source File: StringTest.java From turbo-rpc with Apache License 2.0 | 4 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public byte[] StringUtils2_getLatin1Bytes() throws Exception { return UnsafeStringUtils.getLatin1Bytes(str); }
Example 20
Source File: StringTest.java From turbo-rpc with Apache License 2.0 | 4 votes |
@Benchmark @BenchmarkMode({ Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) public String instanceByNew() { return new String(); }