Git Product home page Git Product logo

rules_jmh's Introduction

rules_jmh

Bazel rules for generating and running microbenchmarks with JMH.

Usage

Load the JMH dependencies in your WORKSPACE file

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
  name = "rules_jmh",
  strip_prefix = "buchgr-rules_jmh-6ccf8d7",
  url = "https://github.com/buchgr/rules_jmh/zipball/6ccf8d7b270083982e5c143935704b9f3f18b256",
  type = "zip",
  sha256 = "dbb7d7e5ec6e932eddd41b910691231ffd7b428dff1ef9a24e4a9a59c1a1762d",
)

load("@rules_jmh//:deps.bzl", "rules_jmh_deps")
rules_jmh_deps()
load("@rules_jmh//:defs.bzl", "rules_jmh_maven_deps")
rules_jmh_maven_deps()

You can specify JMH benchmarks by using the jmh_java_benchmarks rule. It takes the same arguments as java_binary except for main_class. One can specify one or more JMH benchmarks in the srcs attribute.

load("@rules_jmh//:defs.bzl", "jmh_java_benchmarks")

jmh_java_benchmarks(
    name = "example-benchmarks",
    srcs = ["Benchmark1.java", "Benchmark2.java"]
)

You can run the benchmark //:example-benchmarks using bazel run.

$ bazel run :example-benchmarks

and also pass JMH command line flags

$ bazel run :example-benchmarks -- -f 0 -bm avgt

Alternatively you can also build a standalone fat (deploy) jar that contains all dependencies and can be run without Bazel

# Build the jar file
$ bazel build :example-benchmarks_deploy.jar
# Shutdown Bazel for it to not interfere with your benchmark
$ bazel shutdown
# Run the benchmark
$ java -jar bazel-bin/example-benchmarks_deploy.jar

rules_jmh's People

Contributors

buchgr avatar

Stargazers

Xi Chen avatar 牧游人 avatar Poulad Ashrafpour avatar Jonathon Belotti avatar Alexander Lukyanchikov avatar  avatar timothy avatar  avatar Kalyanaraman Santhanam avatar Paul Cody Johnston avatar Jin avatar

Watchers

James Cloos avatar  avatar

rules_jmh's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.