GithubHelp home page GithubHelp logo

sayi / jmh-visual-chart Goto Github PK

View Code? Open in Web Editor NEW
38.0 4.0 7.0 214 KB

:bar_chart: A visual chart for Java MicroBenchmark Harness.

Home Page: http://deepoove.com/jmh-visual-chart/

License: MIT License

CSS 31.29% HTML 35.25% JavaScript 33.46%
jmh visual chart report benchmark

jmh-visual-chart's Introduction

JMH-visual-chart

基于JMH基准测试实现「一组参数不同方法维度」的可视化度量。

一组参数不同方法维度 是指参数在不同取值组合情况下,不同方法的基准测试结果的比较。

QuickStart

我们以字符串拼接的基准测试为例。

测试在使用加号和StringBuilder时候的字符串拼接的性能情况,拼接次数由变量length指定,分别测试10次、50次和100次的性能,测试代码如下:

@BenchmarkMode(Mode.Throughput)
@Measurement(iterations = 2, time = 6, timeUnit = TimeUnit.SECONDS)
@Threads(4)
@Fork(2)
@Warmup(iterations = 1)
@State(value = Scope.Benchmark)
public class MyBenchmark {

  @Param(value = { "10", "50", "100" })
  private int length;

  @Benchmark
  public void testStringAdd(Blackhole blackhole) {
    String a = "";
    for (int i = 0; i < length; i++) {
      a += i;
    }
    blackhole.consume(a);
  }

  @Benchmark
  public void testStringBuilderAdd(Blackhole blackhole) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < length; i++) {
      sb.append(i);
    }
    blackhole.consume(sb.toString());
  }

  public static void main(String[] args) throws RunnerException {
    Options opt = new OptionsBuilder()
        .include(MyBenchmark.class.getSimpleName())
        .result("result.json")
        .resultFormat(ResultFormatType.JSON).build();

    new Runner(opt).run();
  }
}

进入可视化页面,上传JMH的JSON格式结果文件result.json(下载result.json示例文件)进行图表渲染:

支持切换横向视图和垂直视图。

页面URL后加上参数?theme=default会切换成白色主题。

图表的右上角支持PNG格式图片的下载。

Why JMH-Visual-chart

http://jmh.morethan.io/是一个非常棒的JMH可视化的页面,提供了「不同方法一组参数维度」的度量。

JMH-Visual-chart尚处于实验性质,我花了几个小时实现了「一组参数不同方法维度」的度量,并且支持一些额外的功能(主题、PNG下载等)。

当有需要的时候,我会回来扩展更多 维度 和更多 样式 的图表。

JMH

《JMH基准测试和JMH-Visual-chart可视化》

OpenJDK Code Tools: jmh

Java Microbenchmark Harness Tutorials

jmh-visual-chart's People

Contributors

sayi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jmh-visual-chart'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.