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

CSS

CSS

David Sawyer McFarland / O'Reilly / 2006-08-24 / USD 34.99

Book Description Web site design has grown up. Unlike the old days, when designers cobbled together chunky HTML, bandwidth-hogging graphics, and a prayer to make their sites look good, Cascading St......一起来看看 《CSS》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具