Groovy压力测试模块 GBench

码农软件 · 软件分类 · 性能测试和优化 · 2019-11-28 06:14:53

软件介绍

GBench 是 Groovy 的压力测试模块,提供 @Benchmark / Benchmark AST Transformation 用于实际程序测试以及 BenchmarkBuilder 用于微测试。

你可以通过在 groovy 文件中增加下面一行代码即可,想起请看 Installation

@Grab('com.googlecode.gbench:gbench:0.3.1-groovy-2.0') // v0.3.1 for Groovy 2.0

@Benchmark 实例:

import gbench.*

class Task {
   
@Benchmark void run() {
       
// task
   
}
}

/* Output:
Task  void run()  user:847000 system:1777000 cpu:2624000 real:4918000
*/

BenchmarkBuilder 实例:

import gbench.*

new BenchmarkBuilder().run {
   
'StringBuilder' {
       
def sb = new StringBuilder()        
        sb
.append('foo')
        sb
.append('bar')
        sb
.append('baz')
        sb
.toString()
   
}
   
'StringBuffer' {
       
def sb = new StringBuffer()        
        sb
.append('foo')
        sb
.append('bar')
        sb
.append('baz')
        sb
.toString()
   
}
}.prettyPrint()

/* Output:
Environment
===========
* Groovy: 2.0.0
* JVM: Java HotSpot(TM) 64-Bit Server VM (23.0-b15, Oracle Corporation)
    * JRE: 1.7.0_04-ea
    * Total Memory: 99.4375 MB
    * Maximum Memory: 1169.8125 MB
* OS: Mac OS X (10.7.3, amd64)

Options
=======
* Warm Up: Auto
* CPU Time Measurement: On

               user  system  cpu  real

StringBuilder   236       0  236   237
StringBuffer    263       0  263   267
*/

本文地址:https://www.codercto.com/soft/d/19949.html

The Black Box Society

The Black Box Society

Frank Pasquale / Harvard University Press / 2015-1-5 / USD 35.00

Every day, corporations are connecting the dots about our personal behavior—silently scrutinizing clues left behind by our work habits and Internet use. The data compiled and portraits created are inc......一起来看看 《The Black Box Society》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试