1452c38cdSMatthias Sohn# Copyright (C) 2019, Matthias Sohn <matthias.sohn@sap.com> 2452c38cdSMatthias Sohn# and other copyright owners as documented in the project's IP log. 3452c38cdSMatthias Sohn# 4452c38cdSMatthias Sohn# This program and the accompanying materials are made available 5452c38cdSMatthias Sohn# under the terms of the Eclipse Distribution License v1.0 which 6452c38cdSMatthias Sohn# accompanies this distribution, is reproduced below, and is 7452c38cdSMatthias Sohn# available at http://www.eclipse.org/org/documents/edl-v10.php 8452c38cdSMatthias Sohn# 9452c38cdSMatthias Sohn# All rights reserved. 10452c38cdSMatthias Sohn# 11452c38cdSMatthias Sohn# Redistribution and use in source and binary forms, with or 12452c38cdSMatthias Sohn# without modification, are permitted provided that the following 13452c38cdSMatthias Sohn# conditions are met: 14452c38cdSMatthias Sohn# 15452c38cdSMatthias Sohn# - Redistributions of source code must retain the above copyright 16452c38cdSMatthias Sohn# notice, this list of conditions and the following disclaimer. 17452c38cdSMatthias Sohn# 18452c38cdSMatthias Sohn# - Redistributions in binary form must reproduce the above 19452c38cdSMatthias Sohn# copyright notice, this list of conditions and the following 20452c38cdSMatthias Sohn# disclaimer in the documentation and/or other materials provided 21452c38cdSMatthias Sohn# with the distribution. 22452c38cdSMatthias Sohn# 23452c38cdSMatthias Sohn# - Neither the name of the Eclipse Foundation, Inc. nor the 24452c38cdSMatthias Sohn# names of its contributors may be used to endorse or promote 25452c38cdSMatthias Sohn# products derived from this software without specific prior 26452c38cdSMatthias Sohn# written permission. 27452c38cdSMatthias Sohn# 28452c38cdSMatthias Sohn# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 29452c38cdSMatthias Sohn# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 30452c38cdSMatthias Sohn# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 31452c38cdSMatthias Sohn# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32452c38cdSMatthias Sohn# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 33452c38cdSMatthias Sohn# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 34452c38cdSMatthias Sohn# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 35452c38cdSMatthias Sohn# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36452c38cdSMatthias Sohn# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37452c38cdSMatthias Sohn# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 38452c38cdSMatthias Sohn# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 39452c38cdSMatthias Sohn# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 40452c38cdSMatthias Sohn# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41452c38cdSMatthias Sohn 42452c38cdSMatthias Sohn# Definitions to run jmh microbenchmarks 43452c38cdSMatthias Sohn 44*7554bdfaSDavid Pursehouseload("@rules_java//java:defs.bzl", "java_binary", "java_plugin") 45*7554bdfaSDavid Pursehouse 46452c38cdSMatthias Sohndef jmh_java_benchmarks(name, srcs, deps = [], tags = [], plugins = [], **kwargs): 47452c38cdSMatthias Sohn """Builds runnable JMH benchmarks. 48452c38cdSMatthias Sohn This rule builds a runnable target for one or more JMH benchmarks 49452c38cdSMatthias Sohn specified as srcs. It takes the same arguments as java_binary, 50452c38cdSMatthias Sohn except for main_class. 51452c38cdSMatthias Sohn """ 52452c38cdSMatthias Sohn plugin_name = "_{}_jmh_annotation_processor".format(name) 53*7554bdfaSDavid Pursehouse java_plugin( 54452c38cdSMatthias Sohn name = plugin_name, 55452c38cdSMatthias Sohn deps = ["//lib/jmh:jmh"], 56452c38cdSMatthias Sohn processor_class = "org.openjdk.jmh.generators.BenchmarkProcessor", 57452c38cdSMatthias Sohn visibility = ["//visibility:private"], 58452c38cdSMatthias Sohn tags = tags, 59452c38cdSMatthias Sohn ) 60*7554bdfaSDavid Pursehouse java_binary( 61452c38cdSMatthias Sohn name = name, 62452c38cdSMatthias Sohn srcs = srcs, 63452c38cdSMatthias Sohn main_class = "org.openjdk.jmh.Main", 64452c38cdSMatthias Sohn deps = deps + ["//lib/jmh:jmh"], 65452c38cdSMatthias Sohn plugins = plugins + [plugin_name], 66452c38cdSMatthias Sohn tags = tags, 67452c38cdSMatthias Sohn **kwargs 68452c38cdSMatthias Sohn ) 69