Code Monkey home page Code Monkey logo

benchmarking's Introduction

Java benchmarks with JMH

This project contains next benchmarks:

  1. Benchmark for demonstration how JVM handle problems with false sharing with @Contended annotation
  2. Benchmark for demonstration how branch prediction behaves on the example of operation with sorted and unsorted array - useful discussion on stackoverflow

Prerequisites

  • Java 8+
  • Gradle

FalseSharingBenchmark

The -XX:-RestrictContended flag is significant.

The output will look like this:

Benchmark                                      Mode  Cnt          Score         Error  Units
ContendedBenchmarks.padded                    thrpt   30  236434399.252 ± 9209297.004  ops/s
ContendedBenchmarks.padded:updatePaddedA      thrpt   30  114409851.688 ± 4803042.336  ops/s
ContendedBenchmarks.padded:updatePaddedB      thrpt   30  122024547.564 ± 5108447.473  ops/s
ContendedBenchmarks.unpadded                  thrpt   30   63941093.638 ± 2478065.296  ops/s
ContendedBenchmarks.unpadded:updateUnpaddedA  thrpt   30   32050855.915 ± 1371581.512  ops/s
ContendedBenchmarks.unpadded:updateUnpaddedB  thrpt   30   31890237.723 ± 1344691.282  ops/s

The default benchmark mode is Throughput and in this case higher value is better

BranchPredictionBenchmark

The output will look like this:

Benchmark                           Mode  Cnt  Score   Error  Units
BranchPredictionBenchmark.sorted    avgt   25  4.289 ± 0.754  ns/op
BranchPredictionBenchmark.unsorted  avgt   25  9.742 ± 0.466  ns/op

Benchmark mode for BranchPredictionBenchmark is AverageTime and in this case lower value is better

For more details about modes in JMH see specification

benchmarking's People

Contributors

artem0 avatar

Watchers

James Cloos avatar Alexpandiyan Chokkan avatar

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.