Example usage for java.util.concurrent TimeUnit MICROSECONDS

List of usage examples for java.util.concurrent TimeUnit MICROSECONDS

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit MICROSECONDS.

Prototype

TimeUnit MICROSECONDS

To view the source code for java.util.concurrent TimeUnit MICROSECONDS.

Click Source Link

Document

Time unit representing one thousandth of a millisecond.

Usage

From source file:io.druid.benchmark.GroupByTypeInterfaceBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)/* ww w.  j  a  v a  2s  .c  o  m*/
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndexStringThenNumeric(Blackhole blackhole) throws Exception {
    QueryRunner<Row> runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    List<Row> results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }

    runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, longFloatQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }
}

From source file:org.apache.druid.benchmark.query.GroupByBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)/*from   w ww  .  j a  va2  s  .  c  om*/
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndex(Blackhole blackhole) {
    QueryToolChest<Row, GroupByQuery> toolChest = factory.getToolchest();
    QueryRunner<Row> theRunner = new FinalizeResultsQueryRunner<>(
            toolChest.mergeResults(factory.mergeRunners(executorService, makeMultiRunners())),
            (QueryToolChest) toolChest);

    Sequence<Row> queryResult = theRunner.run(QueryPlus.wrap(query), Maps.newHashMap());
    List<Row> results = queryResult.toList();

    for (Row result : results) {
        blackhole.consume(result);
    }
}

From source file:org.apache.druid.benchmark.GroupByTypeInterfaceBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)//from  w  w  w  .j a  v  a 2  s  .co m
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndexStringThenLong(Blackhole blackhole) {
    QueryRunner<Row> runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    List<Row> results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }

    runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, longQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }
}

From source file:io.druid.benchmark.GroupByTypeInterfaceBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)/*from  ww  w . j  av  a  2 s .  c om*/
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndexStringThenLong(Blackhole blackhole) throws Exception {
    QueryRunner<Row> runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    List<Row> results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }

    runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, longQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }
}

From source file:org.apache.druid.benchmark.query.GroupByBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)//from w w w .j a  va  2 s.  co m
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndexWithSpilling(Blackhole blackhole) {
    QueryToolChest<Row, GroupByQuery> toolChest = factory.getToolchest();
    QueryRunner<Row> theRunner = new FinalizeResultsQueryRunner<>(
            toolChest.mergeResults(factory.mergeRunners(executorService, makeMultiRunners())),
            (QueryToolChest) toolChest);

    final GroupByQuery spillingQuery = query
            .withOverriddenContext(ImmutableMap.of("bufferGrouperMaxSize", 4000));
    Sequence<Row> queryResult = theRunner.run(QueryPlus.wrap(spillingQuery), Maps.newHashMap());
    List<Row> results = queryResult.toList();

    for (Row result : results) {
        blackhole.consume(result);
    }
}

From source file:org.apache.geode.internal.InternalDataSerializer.java

private static void initializeWellKnownSerializers() {
    // ArrayBlockingQueue does not have zero-arg constructor
    // LinkedBlockingQueue does have zero-arg constructor but no way to get capacity

    classesToSerializers.put("java.lang.String", new WellKnownPdxDS() {
        @Override/* w  ww  .j  a v  a 2s  .c o  m*/
        public boolean toData(Object o, DataOutput out) throws IOException {
            try {
                writeString((String) o, out);
            } catch (UTFDataFormatException ex) {
                // See bug 30428
                String s = "While writing a String of length " + ((String) o).length();
                UTFDataFormatException ex2 = new UTFDataFormatException(s);
                ex2.initCause(ex);
                throw ex2;
            }
            return true;
        }
    });
    classesToSerializers.put("java.net.InetAddress", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            InetAddress address = (InetAddress) o;
            out.writeByte(INET_ADDRESS);
            writeInetAddress(address, out);
            return true;
        }
    });
    classesToSerializers.put("java.net.Inet4Address", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            InetAddress address = (InetAddress) o;
            out.writeByte(INET_ADDRESS);
            writeInetAddress(address, out);
            return true;
        }
    });
    classesToSerializers.put("java.net.Inet6Address", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            InetAddress address = (InetAddress) o;
            out.writeByte(INET_ADDRESS);
            writeInetAddress(address, out);
            return true;
        }
    });
    classesToSerializers.put("java.lang.Class", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Class c = (Class) o;
            if (c.isPrimitive()) {
                writePrimitiveClass(c, out);
            } else {
                out.writeByte(CLASS);
                writeClass(c, out);
            }
            return true;
        }
    });
    classesToSerializers.put("java.lang.Boolean", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Boolean value = (Boolean) o;
            out.writeByte(BOOLEAN);
            writeBoolean(value, out);
            return true;
        }
    });
    classesToSerializers.put("java.lang.Character", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Character value = (Character) o;
            out.writeByte(CHARACTER);
            writeCharacter(value, out);
            return true;
        }
    });
    classesToSerializers.put("java.lang.Byte", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Byte value = (Byte) o;
            out.writeByte(BYTE);
            writeByte(value, out);
            return true;
        }
    });
    classesToSerializers.put("java.lang.Short", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Short value = (Short) o;
            out.writeByte(SHORT);
            writeShort(value, out);
            return true;
        }
    });
    classesToSerializers.put("java.lang.Integer", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Integer value = (Integer) o;
            out.writeByte(INTEGER);
            writeInteger(value, out);
            return true;
        }
    });
    classesToSerializers.put("java.lang.Long", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Long value = (Long) o;
            out.writeByte(LONG);
            writeLong(value, out);
            return true;
        }
    });
    classesToSerializers.put("java.lang.Float", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Float value = (Float) o;
            out.writeByte(FLOAT);
            writeFloat(value, out);
            return true;
        }
    });
    classesToSerializers.put("java.lang.Double", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Double value = (Double) o;
            out.writeByte(DOUBLE);
            writeDouble(value, out);
            return true;
        }
    });
    classesToSerializers.put("[Z", // boolean[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    out.writeByte(BOOLEAN_ARRAY);
                    writeBooleanArray((boolean[]) o, out);
                    return true;
                }
            });
    classesToSerializers.put("[B", // byte[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    byte[] array = (byte[]) o;
                    out.writeByte(BYTE_ARRAY);
                    writeByteArray(array, out);
                    return true;
                }
            });
    classesToSerializers.put("[C", // char[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    out.writeByte(CHAR_ARRAY);
                    writeCharArray((char[]) o, out);
                    return true;
                }
            });
    classesToSerializers.put("[D", // double[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    double[] array = (double[]) o;
                    out.writeByte(DOUBLE_ARRAY);
                    writeDoubleArray(array, out);
                    return true;
                }
            });
    classesToSerializers.put("[F", // float[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    float[] array = (float[]) o;
                    out.writeByte(FLOAT_ARRAY);
                    writeFloatArray(array, out);
                    return true;
                }
            });
    classesToSerializers.put("[I", // int[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    int[] array = (int[]) o;
                    out.writeByte(INT_ARRAY);
                    writeIntArray(array, out);
                    return true;
                }
            });
    classesToSerializers.put("[J", // long[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    long[] array = (long[]) o;
                    out.writeByte(LONG_ARRAY);
                    writeLongArray(array, out);
                    return true;
                }
            });
    classesToSerializers.put("[S", // short[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    short[] array = (short[]) o;
                    out.writeByte(SHORT_ARRAY);
                    writeShortArray(array, out);
                    return true;
                }
            });
    classesToSerializers.put("[Ljava.lang.String;", // String[]
            new WellKnownPdxDS() {
                @Override
                public boolean toData(Object o, DataOutput out) throws IOException {
                    String[] array = (String[]) o;
                    out.writeByte(STRING_ARRAY);
                    writeStringArray(array, out);
                    return true;
                }
            });
    classesToSerializers.put(TimeUnit.NANOSECONDS.getClass().getName(), new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(TIME_UNIT);
            out.writeByte(TIME_UNIT_NANOSECONDS);
            return true;
        }
    });
    classesToSerializers.put(TimeUnit.MICROSECONDS.getClass().getName(), new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(TIME_UNIT);
            out.writeByte(TIME_UNIT_MICROSECONDS);
            return true;
        }
    });
    classesToSerializers.put(TimeUnit.MILLISECONDS.getClass().getName(), new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(TIME_UNIT);
            out.writeByte(TIME_UNIT_MILLISECONDS);
            return true;
        }
    });
    classesToSerializers.put(TimeUnit.SECONDS.getClass().getName(), new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(TIME_UNIT);
            out.writeByte(TIME_UNIT_SECONDS);
            return true;
        }
    });
    classesToSerializers.put("java.util.Date", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Date date = (Date) o;
            out.writeByte(DATE);
            writeDate(date, out);
            return true;
        }
    });
    classesToSerializers.put("java.io.File", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            File file = (File) o;
            out.writeByte(FILE);
            writeFile(file, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.ArrayList", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            ArrayList list = (ArrayList) o;
            out.writeByte(ARRAY_LIST);
            writeArrayList(list, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.LinkedList", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            LinkedList list = (LinkedList) o;
            out.writeByte(LINKED_LIST);
            writeLinkedList(list, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.Vector", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(VECTOR);
            writeVector((Vector) o, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.Stack", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(STACK);
            writeStack((Stack) o, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.HashSet", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            HashSet list = (HashSet) o;
            out.writeByte(HASH_SET);
            writeHashSet(list, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.LinkedHashSet", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(LINKED_HASH_SET);
            writeLinkedHashSet((LinkedHashSet) o, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.HashMap", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            HashMap list = (HashMap) o;
            out.writeByte(HASH_MAP);
            writeHashMap(list, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.IdentityHashMap", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(IDENTITY_HASH_MAP);
            writeIdentityHashMap((IdentityHashMap) o, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.Hashtable", new WellKnownPdxDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(HASH_TABLE);
            writeHashtable((Hashtable) o, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.Properties", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            Properties props = (Properties) o;
            out.writeByte(PROPERTIES);
            writeProperties(props, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.TreeMap", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(TREE_MAP);
            writeTreeMap((TreeMap) o, out);
            return true;
        }
    });
    classesToSerializers.put("java.util.TreeSet", new WellKnownDS() {
        @Override
        public boolean toData(Object o, DataOutput out) throws IOException {
            out.writeByte(TREE_SET);
            writeTreeSet((TreeSet) o, out);
            return true;
        }
    });
    if (is662SerializationEnabled()) {
        classesToSerializers.put("java.math.BigInteger", new WellKnownDS() {
            @Override
            public boolean toData(Object o, DataOutput out) throws IOException {
                out.writeByte(BIG_INTEGER);
                writeBigInteger((BigInteger) o, out);
                return true;
            }
        });
        classesToSerializers.put("java.math.BigDecimal", new WellKnownDS() {
            @Override
            public boolean toData(Object o, DataOutput out) throws IOException {
                out.writeByte(BIG_DECIMAL);
                writeBigDecimal((BigDecimal) o, out);
                return true;
            }
        });
        classesToSerializers.put("java.util.UUID", new WellKnownDS() {
            @Override
            public boolean toData(Object o, DataOutput out) throws IOException {
                out.writeByte(UUID);
                writeUUID((UUID) o, out);
                return true;
            }
        });
        classesToSerializers.put("java.sql.Timestamp", new WellKnownDS() {
            @Override
            public boolean toData(Object o, DataOutput out) throws IOException {
                out.writeByte(TIMESTAMP);
                writeTimestamp((Timestamp) o, out);
                return true;
            }
        });
    }
}

From source file:org.apache.druid.benchmark.GroupByTypeInterfaceBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)/*from w  ww  .j a v a 2 s .  co m*/
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndexStringTwice(Blackhole blackhole) {
    QueryRunner<Row> runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    List<Row> results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }

    runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }
}

From source file:com.netflix.dyno.jedis.DynoJedisPipeline.java

@Override
public Response<Long> expire(final String key, final int seconds) {
    return new PipelineOperation<Long>() {

        @Override/*from  w  w  w . j  a  v  a2  s.  c o m*/
        Response<Long> execute(final Pipeline jedisPipeline) throws DynoException {
            long startTime = System.nanoTime() / 1000;
            try {
                return jedisPipeline.expire(key, seconds);
            } finally {
                long duration = System.nanoTime() / 1000 - startTime;
                opMonitor.recordSendLatency(OpName.EXPIRE.name(), duration, TimeUnit.MICROSECONDS);
            }
        }
    }.execute(key, OpName.EXPIRE);

}

From source file:io.druid.benchmark.GroupByTypeInterfaceBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)/* w  w  w . j  a v  a  2 s.com*/
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleQueryableIndexStringTwice(Blackhole blackhole) throws Exception {
    QueryRunner<Row> runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    List<Row> results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }

    runner = QueryBenchmarkUtil.makeQueryRunner(factory, "qIndex",
            new QueryableIndexSegment("qIndex", queryableIndexes.get(0)));

    results = GroupByTypeInterfaceBenchmark.runQuery(factory, runner, stringQuery);

    for (Row result : results) {
        blackhole.consume(result);
    }
}

From source file:org.apache.druid.benchmark.query.GroupByBenchmark.java

@Benchmark
@BenchmarkMode(Mode.AverageTime)/*from w  w  w.  j av  a 2  s  . c  o  m*/
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndexWithSerde(Blackhole blackhole) {
    QueryToolChest<Row, GroupByQuery> toolChest = factory.getToolchest();
    QueryRunner<Row> theRunner = new FinalizeResultsQueryRunner<>(
            toolChest.mergeResults(
                    new SerializingQueryRunner<>(new DefaultObjectMapper(new SmileFactory()), Row.class,
                            toolChest.mergeResults(factory.mergeRunners(executorService, makeMultiRunners())))),
            (QueryToolChest) toolChest);

    Sequence<Row> queryResult = theRunner.run(QueryPlus.wrap(query), Maps.newHashMap());
    List<Row> results = queryResult.toList();

    for (Row result : results) {
        blackhole.consume(result);
    }
}