“无匹配基准”当从日食中运行JMH时 [英] "No matching benchmarks" when running JMH from main in eclipse

查看:440
本文介绍了“无匹配基准”当从日食中运行JMH时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过在Eclipse中运行Java应用程序来尝试JMH的新功能。我进口和建造jmh样品项目。编译类在/ jmh-samples / target / generated-sources / annotations中结束,在/ target /中有几个JAR,并且从命令行运行microbenchmarks.jar像往常一样工作。



然而,当我执行主要时我总是得到

 没有匹配的基准。拼写错误的正则表达式? 

任何想法?我正在使用版本0.3

解决方案

好的,看起来像默认情况下,jmh在META-INF / Microbenchmarks下查找生成的类, maven构建放在项目的根源之下。但是,eclipse项目的root不在类路径上,因此在IDE中执行它会导致没有找到基准。



我以下列方式运行:


  1. mvn clean package maven安装,没有在eclipse中

  2. 右键单击jmh-samples项目,选择Build
    Path - >用作源文件夹 li>
  3. 现在,您可以使用jmh-samples中的任何基准来执行eclipse中的Java应用程序

由于eclipse与自动生成的文件混淆,所以在问题视图中,您会遇到1000+错误的缺点,但是至少它可以起作用。


I wanted to try out the new feature of JMH by running it as Java Application in eclipse. I imported and built jmh-samples project. Compiled classes ended in /jmh-samples/target/generated-sources/annotations, there are several JARs in /target/ and running microbenchmarks.jar from command line works as usual.

However when I execute main I always get

No matching benchmarks. Miss-spelled regexp?

Any ideas? I am using version 0.3

解决方案

Okay, so looks like by default jmh looks for generated classes under META-INF/Microbenchmarks, which maven build puts under root of the project. However root of the eclipse project is not on the classpath, so executing it in IDE results in "no benchmarks found".

I got it running following way:

  1. mvn clean package (using external maven installation, not embded in eclipse)
  2. Right-click on jmh-samples project, select "Build Path -> Use as a source folder"
  3. You can now run any of the benchmarks from jmh-samples as Java Application in eclipse

On the downside you get like 1000+ "errors" in Problems view, since eclipse gets confused with auto-generated files, but oh well, at least it works.

这篇关于“无匹配基准”当从日食中运行JMH时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆