org.openjdk.jmh.annotations.Setup Java Examples
The following examples show how to use
org.openjdk.jmh.annotations.Setup.
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: BenchmarkGroupByHash.java From presto with Apache License 2.0 | 6 votes |
@Setup public void setup() { switch (dataType) { case "VARCHAR": types = Collections.nCopies(channelCount, VARCHAR); pages = createVarcharPages(POSITIONS, groupCount, channelCount, hashEnabled); break; case "BIGINT": types = Collections.nCopies(channelCount, BIGINT); pages = createBigintPages(POSITIONS, groupCount, channelCount, hashEnabled); break; default: throw new UnsupportedOperationException("Unsupported dataType"); } hashChannel = hashEnabled ? Optional.of(channelCount) : Optional.empty(); channels = new int[channelCount]; for (int i = 0; i < channelCount; i++) { channels[i] = i; } }
Example #2
Source File: BenchmarkTopNOperator.java From presto with Apache License 2.0 | 6 votes |
@Setup public void setup() { executor = newCachedThreadPool(daemonThreadsNamed("test-executor-%s")); scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s")); List<Type> types = ImmutableList.of(DOUBLE, DOUBLE, VARCHAR, DOUBLE); pages = createInputPages(Integer.valueOf(positionsPerPage), types); operatorFactory = TopNOperator.createOperatorFactory( 0, new PlanNodeId("test"), types, Integer.valueOf(topN), ImmutableList.of(0, 2), ImmutableList.of(DESC_NULLS_LAST, ASC_NULLS_FIRST)); }
Example #3
Source File: BenchmarkDecimalOperators.java From presto with Apache License 2.0 | 6 votes |
@Setup public void setup() { addSymbol("d1", DOUBLE); addSymbol("d2", DOUBLE); addSymbol("d3", DOUBLE); addSymbol("d4", DOUBLE); addSymbol("s1", createDecimalType(10, 5)); addSymbol("s2", createDecimalType(7, 2)); addSymbol("s3", createDecimalType(12, 2)); addSymbol("s4", createDecimalType(2, 1)); addSymbol("l1", createDecimalType(35, 10)); addSymbol("l2", createDecimalType(25, 5)); addSymbol("l3", createDecimalType(20, 6)); addSymbol("l4", createDecimalType(25, 8)); generateRandomInputPage(); generateProcessor(expression); }
Example #4
Source File: RedisEncoderBenchmark.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Setup(Level.Trial) public void setup() { byte[] bytes = new byte[256]; content = Unpooled.buffer(bytes.length); content.writeBytes(bytes); ByteBuf testContent = Unpooled.unreleasableBuffer(content.asReadOnly()); List<RedisMessage> rList = new ArrayList<RedisMessage>(arraySize); for (int i = 0; i < arraySize; ++i) { rList.add(new FullBulkStringRedisMessage(testContent)); } redisArray = new ArrayRedisMessage(rList); encoder = new RedisEncoder(); context = new EmbeddedChannelWriteReleaseHandlerContext(pooledAllocator ? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT, encoder) { @Override protected void handleException(Throwable t) { handleUnexpectedException(t); } }; }
Example #5
Source File: BenchmarkArrayDistinct.java From presto with Apache License 2.0 | 6 votes |
@Setup public void setup() { Metadata metadata = createTestMetadataManager(); metadata.addFunctions(extractFunctions(BenchmarkArrayDistinct.class)); ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)); ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder(); Block[] blocks = new Block[TYPES.size()]; for (int i = 0; i < TYPES.size(); i++) { Type elementType = TYPES.get(i); ArrayType arrayType = new ArrayType(elementType); projectionsBuilder.add(new CallExpression( metadata.resolveFunction(QualifiedName.of(name), fromTypes(arrayType)), arrayType, ImmutableList.of(field(i, arrayType)))); blocks[i] = createChannel(POSITIONS, ARRAY_SIZE, arrayType); } ImmutableList<RowExpression> projections = projectionsBuilder.build(); pageProcessor = compiler.compilePageProcessor(Optional.empty(), projections).get(); page = new Page(blocks); }
Example #6
Source File: BenchmarkMapCopy.java From presto with Apache License 2.0 | 6 votes |
@Setup public void setup() { MapType mapType = mapType(VARCHAR, BIGINT); blockBuilder = mapType.createBlockBuilder(null, POSITIONS); for (int position = 0; position < POSITIONS; position++) { BlockBuilder entryBuilder = blockBuilder.beginBlockEntry(); for (int i = 0; i < mapSize; i++) { VARCHAR.writeString(entryBuilder, String.valueOf(ThreadLocalRandom.current().nextInt())); BIGINT.writeLong(entryBuilder, ThreadLocalRandom.current().nextInt()); } blockBuilder.closeEntry(); } dataBlock = blockBuilder.build(); }
Example #7
Source File: BenchmarkInequalityJoin.java From presto with Apache License 2.0 | 6 votes |
@Setup public void setUp() { queryRunner = new MemoryLocalQueryRunner(ImmutableMap.of(SystemSessionProperties.FAST_INEQUALITY_JOINS, fastInequalityJoins)); // t1.val1 is in range [0, 1000) // t1.bucket is in [0, 1000) queryRunner.execute(format( "CREATE TABLE memory.default.t1 AS SELECT " + "orderkey %% %d bucket, " + "(orderkey * 13) %% 1000 val1 " + "FROM tpch.tiny.lineitem", buckets)); // t2.val2 is in range [0, 10) // t2.bucket is in [0, 1000) queryRunner.execute(format( "CREATE TABLE memory.default.t2 AS SELECT " + "orderkey %% %d bucket, " + "(orderkey * 379) %% %d val2 " + "FROM tpch.tiny.lineitem", buckets, filterOutCoefficient)); }
Example #8
Source File: SlicedByteBufBenchmark.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Setup public void setup() { // Use buffer sizes that will also allow to write UTF-8 without grow the buffer ByteBuf buffer = Unpooled.buffer(512).retain(); slicedByteBuf = buffer.slice(0, 256); slicedAbstractByteBuf = buffer.slice(0, 256); if (slicedByteBuf.getClass() == slicedAbstractByteBuf.getClass()) { throw new IllegalStateException(); } StringBuilder asciiSequence = new StringBuilder(128); for (int i = 0; i < 128; i++) { asciiSequence.append('a'); } ascii = asciiSequence.toString(); }
Example #9
Source File: SymSpellSearchBenchMark.java From customized-symspell with MIT License | 6 votes |
@Setup(Level.Iteration) public void setup() throws SpellCheckException, IOException { SpellCheckSettings spellCheckSettings = SpellCheckSettings.builder() .maxEditDistance(maxEditDistance).build(); DataHolder dataHolder = new InMemoryDataHolder(spellCheckSettings, new Murmur3HashFunction()); spellChecker = new SymSpellCheck(dataHolder, getStringDistance(spellCheckSettings, null), spellCheckSettings); indexData(dataFile, dataHolder); System.out.println(" DataHolder Indexed Size " + dataHolder.getSize() ); }
Example #10
Source File: IntObjectHashMapBenchmark.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Setup(Level.Trial) public void setup() { switch(mapType) { case AGRONA: { environment = new AgronaEnvironment(); break; } case NETTY: { environment = new NettyEnvironment(); break; } default: { throw new IllegalStateException("Invalid mapType: " + mapType); } } }
Example #11
Source File: BenchmarkArrayJoin.java From presto with Apache License 2.0 | 6 votes |
@Setup public void setup() { Metadata metadata = createTestMetadataManager(); List<RowExpression> projections = ImmutableList.of(new CallExpression( metadata.resolveFunction(QualifiedName.of("array_join"), fromTypes(new ArrayType(BIGINT), VARCHAR)), VARCHAR, ImmutableList.of(field(0, new ArrayType(BIGINT)), constant(Slices.wrappedBuffer(",".getBytes(UTF_8)), VARCHAR)))); pageProcessor = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)) .compilePageProcessor(Optional.empty(), projections) .get(); page = new Page(createChannel(POSITIONS, ARRAY_SIZE)); }
Example #12
Source File: BenchmarkHashBuildAndJoinOperators.java From presto with Apache License 2.0 | 6 votes |
@Setup public void setup() { switch (hashColumns) { case "varchar": hashChannels = Ints.asList(0); break; case "bigint": hashChannels = Ints.asList(1); break; case "all": hashChannels = Ints.asList(0, 1, 2); break; default: throw new UnsupportedOperationException(format("Unknown hashColumns value [%s]", hashColumns)); } executor = newCachedThreadPool(daemonThreadsNamed("test-executor-%s")); scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s")); initializeBuildPages(); }
Example #13
Source File: BenchmarkNodeScheduler.java From presto with Apache License 2.0 | 5 votes |
@Setup public void setup() { TestingTransactionHandle transactionHandle = TestingTransactionHandle.create(); finalizerService.start(); NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService); ImmutableList.Builder<InternalNode> nodeBuilder = ImmutableList.builder(); for (int i = 0; i < NODES; i++) { nodeBuilder.add(new InternalNode("node" + i, URI.create("http://" + addressForHost(i).getHostText()), NodeVersion.UNKNOWN, false)); } List<InternalNode> nodes = nodeBuilder.build(); MockRemoteTaskFactory remoteTaskFactory = new MockRemoteTaskFactory( newCachedThreadPool(daemonThreadsNamed("remoteTaskExecutor-%s")), newScheduledThreadPool(2, daemonThreadsNamed("remoteTaskScheduledExecutor-%s"))); for (int i = 0; i < nodes.size(); i++) { InternalNode node = nodes.get(i); ImmutableList.Builder<Split> initialSplits = ImmutableList.builder(); for (int j = 0; j < MAX_SPLITS_PER_NODE + MAX_PENDING_SPLITS_PER_TASK_PER_NODE; j++) { initialSplits.add(new Split(CONNECTOR_ID, new TestSplitRemote(i), Lifespan.taskWide())); } TaskId taskId = new TaskId("test", 1, i); MockRemoteTaskFactory.MockRemoteTask remoteTask = remoteTaskFactory.createTableScanTask(taskId, node, initialSplits.build(), nodeTaskMap.createPartitionedSplitCountTracker(node, taskId)); nodeTaskMap.addTask(node, remoteTask); taskMap.put(node, remoteTask); } for (int i = 0; i < SPLITS; i++) { splits.add(new Split(CONNECTOR_ID, new TestSplitRemote(ThreadLocalRandom.current().nextInt(DATA_NODES)), Lifespan.taskWide())); } InMemoryNodeManager nodeManager = new InMemoryNodeManager(); nodeManager.addNode(CONNECTOR_ID, nodes); NodeScheduler nodeScheduler = new NodeScheduler(getNodeSelectorFactory(nodeManager, nodeTaskMap)); nodeSelector = nodeScheduler.createNodeSelector(Optional.of(CONNECTOR_ID)); }
Example #14
Source File: BenchmarkSTEnvelope.java From presto with Apache License 2.0 | 5 votes |
@Setup public void setup() throws IOException { complexGeometry = GeoFunctions.stGeometryFromText(Slices.utf8Slice(loadPolygon("large_polygon.txt"))); simpleGeometry = GeoFunctions.stGeometryFromText(Slices.utf8Slice("POLYGON ((1 1, 4 1, 1 4))")); }
Example #15
Source File: BenchmarkArrayAggregation.java From presto with Apache License 2.0 | 5 votes |
@Setup(Invocation) public void setup() { Metadata metadata = createTestMetadataManager(); Block block; Type elementType; switch (type) { case "BIGINT": elementType = BIGINT; break; case "VARCHAR": elementType = VARCHAR; break; case "DOUBLE": elementType = DOUBLE; break; case "BOOLEAN": elementType = BOOLEAN; break; default: throw new UnsupportedOperationException(); } ResolvedFunction resolvedFunction = metadata.resolveFunction(QualifiedName.of("array_agg"), fromTypes(elementType)); InternalAggregationFunction function = metadata.getAggregateFunctionImplementation(resolvedFunction); accumulator = function.bind(ImmutableList.of(0), Optional.empty()).createAccumulator(); block = createChannel(ARRAY_SIZE, elementType); page = new Page(block); }
Example #16
Source File: BenchmarkGroupedTypedHistogram.java From presto with Apache License 2.0 | 5 votes |
@Setup public void setUp() { pages = new Page[numGroups]; groupByIdBlocks = new GroupByIdBlock[numGroups]; for (int j = 0; j < numGroups; j++) { List<String> valueList = new ArrayList<>(); for (int i = 0; i < rowCount; i++) { // makes sure rows don't exceed rowSize String str = String.valueOf(i % 10); String item = IntStream.range(0, rowSize).mapToObj(x -> str).collect(Collectors.joining()); boolean distinctValue = random.nextDouble() < distinctFraction; if (distinctValue) { // produce a unique value for the histogram valueList.add(j + "-" + item); } else { valueList.add(item); } } Block block = createStringsBlock(valueList); Page page = new Page(block); GroupByIdBlock groupByIdBlock = AggregationTestUtils.createGroupByIdBlock(j, page.getPositionCount()); pages[j] = page; groupByIdBlocks[j] = groupByIdBlock; } InternalAggregationFunction aggregationFunction = getInternalAggregationFunctionVarChar(histogramGroupImplementation); groupedAccumulator = createGroupedAccumulator(aggregationFunction); }
Example #17
Source File: BenchmarkArrayIntersect.java From presto with Apache License 2.0 | 5 votes |
@Setup public void setup() { Type elementType; switch (type) { case "BIGINT": elementType = BIGINT; break; case "VARCHAR": elementType = VARCHAR; break; case "DOUBLE": elementType = DOUBLE; break; case "BOOLEAN": elementType = BOOLEAN; break; default: throw new UnsupportedOperationException(); } Metadata metadata = createTestMetadataManager(); ArrayType arrayType = new ArrayType(elementType); ImmutableList<RowExpression> projections = ImmutableList.of(new CallExpression( metadata.resolveFunction(QualifiedName.of(name), fromTypes(arrayType, arrayType)), arrayType, ImmutableList.of(field(0, arrayType), field(1, arrayType)))); ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)); pageProcessor = compiler.compilePageProcessor(Optional.empty(), projections).get(); page = new Page(createChannel(POSITIONS, arraySize, elementType), createChannel(POSITIONS, arraySize, elementType)); }
Example #18
Source File: HpackDecoderULE128Benchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Setup public void setup() { byte[] longMax = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x7F}; longMaxBuf = Unpooled.wrappedBuffer(longMax); byte[] intMax = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x07}; intMaxBuf = Unpooled.wrappedBuffer(intMax); }
Example #19
Source File: BenchmarkBlockDataToString.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@Setup public void createData() { ThreadLocalRandom rnd = ThreadLocalRandom.current(); data = new ArrayList<>(count); values = new ArrayList<>(count); for (int i = 0; i < count; i++) { BlockID blockID = new BlockID(rnd.nextLong(), rnd.nextLong()); BlockData item = new BlockData(blockID); item.setBlockCommitSequenceId(rnd.nextLong()); data.add(item); values.add(item.toString()); } }
Example #20
Source File: BenchmarkDecimalOperators.java From presto with Apache License 2.0 | 5 votes |
@Setup public void setup() { addSymbol("v1", createDecimalType(Integer.valueOf(precision), SCALE)); String expression = "CAST(v1 AS VARCHAR)"; generateRandomInputPage(); generateProcessor(expression); }
Example #21
Source File: DistkvStrBenchmark.java From distkv with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Setup public void init() { TestUtil.startRpcServer(8082); asyncClient = new DefaultAsyncClient(PROTOCOL); client = new DefaultDistkvClient(PROTOCOL); client.strs().put(KEY_STR_SYNC, VALUE_STR_SYNC); asyncClient.strs().put(KEY_STR_ASYNC, VALUE_STR_ASYNC); }
Example #22
Source File: FHIRValueSetBenchmarks.java From FHIR with Apache License 2.0 | 5 votes |
@Setup public void setUp() throws Exception { Reader reader = ExamplesUtil.resourceReader("json/ibm/valueset/ValueSet-large.json"); valueSet = FHIRParser.parser(Format.JSON).parse(reader); List<Contains> concepts = valueSet.getExpansion().getContains(); // naive attempt to force the worst case concept = concepts.get(concepts.size() - 1); }
Example #23
Source File: BenchMarkSCM.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@Setup(Level.Trial) public static void initialize() throws Exception { try { lock.lock(); if (scm == null) { OzoneConfiguration conf = new OzoneConfiguration(); testDir = GenesisUtil.getTempPath() .resolve(RandomStringUtils.randomNumeric(7)).toString(); conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir); GenesisUtil.configureSCM(conf, 10); conf.setInt(OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT, numContainersPerPipeline); GenesisUtil.addPipelines(ReplicationFactor.THREE, numPipelines, conf); scm = GenesisUtil.getScm(conf, new SCMConfigurator()); scm.start(); blockManager = scm.getScmBlockManager(); // prepare SCM PipelineManager pipelineManager = scm.getPipelineManager(); for (Pipeline pipeline : pipelineManager .getPipelines(ReplicationType.RATIS, ReplicationFactor.THREE)) { pipelineManager.openPipeline(pipeline.getId()); } scm.getEventQueue().fireEvent(SCMEvents.SAFE_MODE_STATUS, new SCMSafeModeManager.SafeModeStatus(false, false)); Thread.sleep(1000); } } finally { lock.unlock(); } }
Example #24
Source File: NoPriorityByteDistributionBenchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Setup(Level.Trial) public void setupTrial() throws Exception { connection = new DefaultHttp2Connection(false); dataRefresherKey = connection.newKey(); // Create the flow controller switch (algorithm) { case WFQ: distributor = new WeightedFairQueueByteDistributor(connection, 0); break; case UNIFORM: distributor = new UniformStreamByteDistributor(connection); break; } controller = new DefaultHttp2RemoteFlowController(connection, new ByteCounter(distributor)); connection.remote().flowController(controller); Http2ConnectionHandler handler = new Http2ConnectionHandlerBuilder() .encoderEnforceMaxConcurrentStreams(false).validateHeaders(false) .frameListener(new Http2FrameAdapter()) .connection(connection) .build(); ctx = new EmbeddedChannelWriteReleaseHandlerContext(PooledByteBufAllocator.DEFAULT, handler) { @Override protected void handleException(Throwable t) { handleUnexpectedException(t); } }; handler.handlerAdded(ctx); handler.channelActive(ctx); // Create the streams, each initialized with MAX_INT bytes. for (int i = 0; i < numStreams; ++i) { Http2Stream stream = connection.local().createStream(toStreamId(i), false); addData(stream, Integer.MAX_VALUE); stream.setProperty(dataRefresherKey, new DataRefresher(stream)); } }
Example #25
Source File: BenchmarkStringFunctions.java From presto with Apache License 2.0 | 5 votes |
@Setup public void setup() { Slice whitespace = createRandomUtf8Slice(ascii ? ASCII_WHITESPACE : ALL_WHITESPACE, length + 1); leftWhitespace = Slices.copyOf(whitespace); leftWhitespace.setByte(leftWhitespace.length() - 1, 'X'); rightWhitespace = Slices.copyOf(whitespace); rightWhitespace.setByte(0, 'X'); bothWhitespace = Slices.copyOf(whitespace); bothWhitespace.setByte(length / 2, 'X'); }
Example #26
Source File: FHIRParserBenchmark.java From FHIR with Apache License 2.0 | 5 votes |
@Setup public void setUp() throws IOException { if (exampleName == null) { System.err.println("exampleName is null; if you're in Eclipse then make sure annotation processing is on and you've ran 'mvn clean package'."); System.exit(1); } System.out.println("Setting up for example " + exampleName); context = FhirContext.forR4(); context.setParserErrorHandler(new StrictErrorHandler()); JSON_SPEC_EXAMPLE = BenchmarkUtil.getSpecExample(Format.JSON, exampleName); XML_SPEC_EXAMPLE = BenchmarkUtil.getSpecExample(Format.XML, exampleName); }
Example #27
Source File: BenchmarkWindowOperator.java From presto with Apache License 2.0 | 5 votes |
@Setup public void setup() { executor = newCachedThreadPool(daemonThreadsNamed("test-executor-%s")); scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s")); createOperatorFactoryAndGenerateTestData(numberOfPregroupedColumns); }
Example #28
Source File: BenchmarkLongBitPacker.java From presto with Apache License 2.0 | 5 votes |
@Setup public void setup() { byte[] bytes = new byte[256 * 64]; ThreadLocalRandom.current().nextBytes(bytes); input = Slices.wrappedBuffer(bytes).getInput(); }
Example #29
Source File: BenchmarkSpatialJoin.java From presto with Apache License 2.0 | 5 votes |
@Setup(Level.Invocation) public void createPointsTable() { // Generate random points within the approximate bounding box of the US polygon: // POLYGON ((-124 27, -65 27, -65 49, -124 49, -124 27)) queryRunner.execute(format("CREATE TABLE memory.default.points AS " + "SELECT 'p' || cast(elem AS VARCHAR) as name, xMin + (xMax - xMin) * random() as longitude, yMin + (yMax - yMin) * random() as latitude " + "FROM (SELECT -124 AS xMin, -65 AS xMax, 27 AS yMin, 49 AS yMax) " + "CROSS JOIN UNNEST(sequence(1, %s)) AS t(elem)", pointCount)); }
Example #30
Source File: DistkvSetBenchmark.java From distkv with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Setup public void init() { TestUtil.startRpcServer(8082); dummyData = ImmutableSet.of( RandomStringUtils.random(5), RandomStringUtils.random(5), RandomStringUtils.random(5)); asyncClient = new DefaultAsyncClient(PROTOCOL); client = new DefaultDistkvClient(PROTOCOL); client.sets().put(KEY_SET_SYNC,dummyData); asyncClient.sets().put(KEY_SET_ASYNC,dummyData); }