问题描述
我想通过在Eclipse中运行Java应用程序来尝试JMH的新功能。我进口和建造jmh样品项目。编译类在/ jmh-samples / target / generated-sources / annotations中结束,在/ target /中有几个JAR,并且从命令行运行microbenchmarks.jar像往常一样工作。然而,当我执行主要时我总是得到
没有匹配的基准。拼写错误的正则表达式?
任何想法?我正在使用版本0.3
好的,看起来像默认情况下,jmh在META-INF / Microbenchmarks下查找生成的类, maven构建放在项目的根源之下。但是,eclipse项目的root不在类路径上,因此在IDE中执行它会导致没有找到基准。
我以下列方式运行:
- mvn clean package maven安装,没有在eclipse中
) - 右键单击jmh-samples项目,选择Build
Path - >用作源文件夹 li>
- 现在,您可以使用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:
- mvn clean package (using external maven installation, not embdedin eclipse)
- Right-click on jmh-samples project, select "BuildPath -> Use as a source folder"
- 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时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!