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 Project: presto Author: prestosql File: BenchmarkTopNOperator.java License: 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 #2
Source Project: presto Author: prestosql File: BenchmarkDecimalOperators.java License: 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 #3
Source Project: netty-4.1.22 Author: tianheframe File: RedisEncoderBenchmark.java License: 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 #4
Source Project: presto Author: prestosql File: BenchmarkArrayDistinct.java License: 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 #5
Source Project: presto Author: prestosql File: BenchmarkMapCopy.java License: 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 #6
Source Project: presto Author: prestosql File: BenchmarkInequalityJoin.java License: 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 #7
Source Project: netty-4.1.22 Author: tianheframe File: SlicedByteBufBenchmark.java License: 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 #8
Source Project: customized-symspell Author: MighTguY File: SymSpellSearchBenchMark.java License: 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 #9
Source Project: netty-4.1.22 Author: tianheframe File: IntObjectHashMapBenchmark.java License: 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 #10
Source Project: presto Author: prestosql File: BenchmarkArrayJoin.java License: 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 #11
Source Project: presto Author: prestosql File: BenchmarkHashBuildAndJoinOperators.java License: 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 #12
Source Project: presto Author: prestosql File: BenchmarkGroupByHash.java License: 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 #13
Source Project: smithy Author: awslabs File: Selectors.java License: Apache License 2.0 | 5 votes |
@Setup public void prepare() { model = Model.assembler() .addImport(Selectors.class.getResource("http-model.smithy")) .assemble() .getResult() .get(); }
Example #14
Source Project: FHIR Author: IBM File: FHIRValueSetBenchmarks.java License: Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Setup public void setUp() throws Exception { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("ValueSet-large-HashSet.ser"); try (ObjectInputStream is = new ObjectInputStream(in)) { set = (Set<String>) is.readObject(); } }
Example #15
Source Project: hadoop-ozone Author: apache File: BenchmarkBlockDataToString.java License: 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 #16
Source Project: hadoop-ozone Author: apache File: BenchMarkSCM.java License: 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 #17
Source Project: presto Author: prestosql File: BenchmarkBigIntOperators.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() { leftOperand0 = 1; leftOperand1 = 20; leftOperand2 = 33; leftOperand3 = 407; leftOperand4 = 7890; rightOperand0 = 123456; rightOperand1 = 9003; rightOperand2 = 809; rightOperand3 = 67; rightOperand4 = 5; }
Example #18
Source Project: grpc-nebula-java Author: grpc-nebula File: WriteBenchmark.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() { context = Context.ROOT; for (int i = 0; i < preexistingKeys; i++) { context = context.withValue(Context.key("preexisting_key" + i), val); } }
Example #19
Source Project: presto Author: prestosql File: BenchmarkReorderChainedJoins.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() { Session session = testSessionBuilder() .setSystemProperty("join_reordering_strategy", joinReorderingStrategy) .setSystemProperty("join_distribution_type", "AUTOMATIC") .setCatalog("tpch") .setSchema("tiny") .build(); queryRunner = LocalQueryRunner.create(session); queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of()); }
Example #20
Source Project: FHIR Author: IBM File: FHIRParserBenchmark.java License: 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 #21
Source Project: customized-symspell Author: MighTguY File: SymSpellIndexBenchMark.java License: MIT License | 5 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); }
Example #22
Source Project: grpc-nebula-java Author: grpc-nebula File: UnaryCallQpsBenchmark.java License: Apache License 2.0 | 5 votes |
/** * Setup with direct executors, small payloads and a large flow control window. */ @Setup(Level.Trial) public void setup() throws Exception { super.setup(ExecutorType.DIRECT, ExecutorType.DIRECT, MessageSize.SMALL, MessageSize.SMALL, FlowWindowSize.LARGE, ChannelType.NIO, maxConcurrentStreams, channelCount); callCounter = new AtomicLong(); completed = new AtomicBoolean(); startUnaryCalls(maxConcurrentStreams, callCounter, completed, 1); }
Example #23
Source Project: netty-4.1.22 Author: tianheframe File: ByteBufBenchmark.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() { byteBuffer = ByteBuffer.allocate(8); directByteBuffer = ByteBuffer.allocateDirect(8); buffer = Unpooled.buffer(8); directBuffer = Unpooled.directBuffer(8); directBufferPooled = PooledByteBufAllocator.DEFAULT.directBuffer(8); }
Example #24
Source Project: presto Author: prestosql File: BenchmarkJsonToMapCast.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() { Type valueType; switch (valueTypeName) { case "BIGINT": valueType = BIGINT; break; case "DOUBLE": valueType = DOUBLE; break; case "VARCHAR": valueType = VARCHAR; break; default: throw new UnsupportedOperationException(); } Metadata metadata = createTestMetadataManager(); MapType mapType = mapType(VARCHAR, valueType); List<RowExpression> projections = ImmutableList.of(new CallExpression( metadata.getCoercion(JSON, mapType), mapType, ImmutableList.of(field(0, JSON)))); pageProcessor = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)) .compilePageProcessor(Optional.empty(), projections) .get(); page = new Page(createChannel(POSITION_COUNT, MAP_SIZE, valueType)); }
Example #25
Source Project: grpc-nebula-java Author: grpc-nebula File: HandlerRegistryBenchmark.java License: Apache License 2.0 | 5 votes |
/** * Set up the registry. */ @Setup(Level.Trial) public void setup() throws Exception { registry = new MutableHandlerRegistry(); fullMethodNames = new ArrayList<>(serviceCount * methodCountPerService); for (int serviceIndex = 0; serviceIndex < serviceCount; ++serviceIndex) { String serviceName = randomString(); ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition.builder(serviceName); for (int methodIndex = 0; methodIndex < methodCountPerService; ++methodIndex) { String methodName = randomString(); MethodDescriptor<Void, Void> methodDescriptor = MethodDescriptor.<Void, Void>newBuilder() .setType(MethodDescriptor.MethodType.UNKNOWN) .setFullMethodName(MethodDescriptor.generateFullMethodName(serviceName, methodName)) .setRequestMarshaller(TestMethodDescriptors.voidMarshaller()) .setResponseMarshaller(TestMethodDescriptors.voidMarshaller()) .build(); serviceBuilder.addMethod(methodDescriptor, new ServerCallHandler<Void, Void>() { @Override public Listener<Void> startCall(ServerCall<Void, Void> call, Metadata headers) { return null; } }); fullMethodNames.add(methodDescriptor.getFullMethodName()); } registry.addService(serviceBuilder.build()); } }
Example #26
Source Project: presto Author: prestosql File: BenchmarkEnvelopeIntersection.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() { geometry = stGeometryFromText(utf8Slice("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))")); otherGeometry = stGeometryFromText(utf8Slice("POLYGON ((0.5 0.5, 0.5 1.5, 1.5 1.5, 1.5 0.5, 0.5 0.5))")); envelope = stEnvelope(geometry); otherEnvelope = stEnvelope(otherGeometry); }
Example #27
Source Project: netty-4.1.22 Author: tianheframe File: HeapByteBufBenchmark.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() throws Exception { unsafeBuffer = newBuffer("io.netty.buffer.UnpooledUnsafeHeapByteBuf"); buffer = newBuffer("io.netty.buffer.UnpooledHeapByteBuf"); unsafeBuffer.writeLong(1L); buffer.writeLong(1L); }
Example #28
Source Project: presto Author: prestosql File: BenchmarkGeometryToBingTiles.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() throws IOException { Path filePath = Paths.get(this.getClass().getClassLoader().getResource("large_polygon.txt").getPath()); List<String> lines = Files.readAllLines(filePath); String line = lines.get(0); String[] parts = line.split("\\|"); String wkt = parts[0]; geometry = GeoFunctions.stGeometryFromText(Slices.utf8Slice(wkt)); envelope = GeoFunctions.stEnvelope(geometry); zoomLevel = Integer.parseInt(parts[1]); }
Example #29
Source Project: presto Author: prestosql File: BenchmarkRegexpFunctions.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() { SliceOutput sliceOutput = new DynamicSliceOutput(sourceLength); Slice pattern; switch (patternString) { case ".*x.*": pattern = Slices.utf8Slice(".*x.*"); IntStream.generate(() -> 97).limit(sourceLength).forEach(sliceOutput::appendByte); break; case ".*(x|y).*": pattern = Slices.utf8Slice(".*(x|y).*"); IntStream.generate(() -> 97).limit(sourceLength).forEach(sliceOutput::appendByte); break; case "longdotstar": pattern = Slices.utf8Slice(".*coolfunctionname.*"); ThreadLocalRandom.current().ints(97, 123).limit(sourceLength).forEach(sliceOutput::appendByte); break; case "phone": pattern = Slices.utf8Slice("\\d{3}/\\d{3}/\\d{4}"); // 47: '/', 48-57: '0'-'9' ThreadLocalRandom.current().ints(47, 58).limit(sourceLength).forEach(sliceOutput::appendByte); break; case "literal": pattern = Slices.utf8Slice("literal"); // 97-122: 'a'-'z' ThreadLocalRandom.current().ints(97, 123).limit(sourceLength).forEach(sliceOutput::appendByte); break; default: throw new IllegalArgumentException("pattern: " + patternString + " not supported"); } joniPattern = joniRegexp(pattern); re2JPattern = re2JRegexp(pattern); source = sliceOutput.slice(); checkState(source.length() == sourceLength, "source.length=%s, sourceLength=%s", source.length(), sourceLength); }
Example #30
Source Project: sdn-rx Author: neo4j File: Benchmarks.java License: Apache License 2.0 | 5 votes |
@Setup public void setup() { Map<String, Object> neo4jConfig = prepareNeo4j(); SpringApplication springApplication = new SpringApplication(); springApplication.addPrimarySources(Collections.singletonList(Application.class)); springApplication.setLazyInitialization(true); springApplication.setDefaultProperties(neo4jConfig); this.applicationContext = springApplication.run(); this.movieRepository = applicationContext.getBean(MovieRepository.class); this.driver = applicationContext.getBean(Driver.class); }