简体   繁体   English

自动化性能测试框架

[英]Automated performance testing framework

Is there a framework to write automated performance tests on the JVM ? 是否有在JVM上编写自动化性能测试的框架?

I would like to set some performance targets and flash a red light (or rather print a red console message) everytime the perfomance is below the goal. 我希望设置一些性能目标并在每次性能低于目标时闪烁红灯(或者更确切地说是打印红色控制台消息)。

I have some benchmarks written with Calliper that I run manually, however I would like the performance test suite, to be run automatically as I do for unit-testing. 我有一些用Calliper编写的基准测试,我手动运行,但是我希望性能测试套件能像我单元测试一样自动运行。

No databases, or web server. 没有数据库或Web服务器。

Since 4-th version JUnit supports that functionality: 由于第4版JUnit支持该功能:

import org.junit.*;

public class JunitTest4 {

    // timings below are in milliseconds
    @Test(timeout = 1000)  
    public void infinity() {
        // will fail    
        while (true);  
    }  

}

But sadly, it just a basic functionality, not sure you'll be completely pleased: you can't measure something less than millisecond, you can't store history line for tests, you can't see how far you're from the goal. 但遗憾的是,它只是一个基本的功能,不确定你会非常高兴:你不能测量小于毫秒的东西,你不能存储测试的历史记录,你不能看到你离这个有多远目标。

I'm not a performance testing specialist, so I can't judge how difficult this would be to implement, but it should be possible with JUnit Rules. 我不是性能测试专家,所以我无法判断实现它的难度,但是应该可以使用JUnit Rules。

It would work similar to the @Test annotation mentioned by om-nom-nom, but you would provide a rule which for example runs each test 100 times for warm up than runs it 100 times and calculates the stdev and fails the test when average time is 2 stdevs larger then the set timeoiut. 它的工作方式类似于om-nom-nom提到的@Test注释,但是你会提供一个规则,例如每次测试运行100次以进行预热而不是运行100次并计算stdev并在平均时间内未通过测试比设定的timeoiut大2个stdevs。 ... Or whatever the rules should be. ......或者无论规则应该是什么。

Here is an article to JUnit Rules . 这是JUnit规则一篇文章

Basically the same approach should work with ScalaTest 基本上相同的方法应该适用于ScalaTest

当我问这个问题时, ScalaMeter工具包完全符合我的要求。

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

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