简体   繁体   English

带图形输出的轻量级微基准库(Java)

[英]Lightweight microbenchmark library with graph output (Java)

Is there a good Java library for taking the legwork out of writing good micro-benchmarks? 是否有一个很好的Java库可以帮助您完成编写良好的微基准测试的工作量? I'm thinking something which can provide (with a minimum of hassle) provide text (CSV or HTML, take your pick) output of results and maybe graphs summarizing results. 我正在考虑能够提供(尽量减少麻烦)提供文本(CSV或HTML,选择)输出结果的图表,以及总结结果的图表。 Ideally, it should be something that plays nicely with JUnit or equivalent, and should be simple to configure benchmarks with variable parameters. 理想情况下,它应该是与JUnit或等效的一起使用的东西,应该很容易配置带有可变参数的基准。

I've looked at japex, but found it too heavyweight ( 25 MB of libraries to include?!) and frankly it was just a pain to work with. 我看过japex,但发现它太重了(包括25 MB的库?!)而且坦率地说这只是一种痛苦。 Virtually nonexistent documentation, mucking about with ant, XML, and paths... etc. 几乎不存在的文档,与ant,XML和路径等相关...等等。

A few of us from the Google Collections team are in the early days of building something that satisfies your needs. Google Collections团队中的一些人正处于建设满足您需求的早期阶段 Here's the code to measure how long foo() takes: 这是测量foo()采用时间的代码:

public class Benchmark1 extends SimpleBenchmark {
  public void timeFoo(int reps) {
    for (int i = 0; i < reps; i++) {
      foo();
    }
  }
}

Neither the API nor the tool itself is particularly stable. API和工具本身都不是特别稳定。 We aren't even ready to receive bug reports or feature requests! 我们甚至没有准备好接收错误报告或功能请求! If I haven't scared you off yet, I invite you to take Caliper for a spin. 如果我还没有吓到你,我邀请你带上卡尺

Oracle now has JMH. Oracle现在拥有JMH。 Not only is it written by members of the JIT team (who will take out much of the legwork of writing good micro-benchmarks), but it also has other neat features like pluggable profilers (including those that will print assembly of your hotspots with per-line cpu time). 它不仅是由JIT团队的成员编写的(他们将完成编写优秀微基准测试的大部分工作),而且还具有其他简洁的功能,如可插拔的剖析器(包括那些将打印热点组件的人) -line cpu time)。

It prints out tables. 它打印出表格。 Not sure about graphs. 关于图表不确定。 The benchmarks can be configured with variable parameters. 可以使用可变参数配置基准。 The documentation is fairly good. 文档相当不错。

It is easy to set up and get going. 它很容易设置和开始。 I've got it integrated with JUnit, but the developers provide a Maven archetype to get started. 我已经将它与JUnit集成,但是开发人员提供了一个Maven原型来开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM