-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME
More file actions
138 lines (95 loc) · 3.11 KB
/
README
File metadata and controls
138 lines (95 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
OVERVIEW
--------
GBench is a benchmarking module for Groovy. It allows you to compare the
performance of programs.
GBench has two features: Benchmark Builder and Benchmark Transformation.
Benchmark Builder allows you to correctly benchmark programs. Groovy is a
difficult language to accurately benchmark. Method caching, dynamic
optimization and garbage collection by JVM, there are many factors that
interfere measurement. You can resolve the issues by using BenchmarkBuilder.
See also "Right Groovy Benchmarking" at
http://blog.masatonagai.com/2012/03/right-groovy-benchmarking.html
for understanding what the "correctly" means.
Benchmark Transformation allows you to measure methods’ execution time
without additional code.
VERSIONING
----------
GBench has different versions for different Groovy versions.
[major].[minor].[maintenance]-groovy-[groovy_major].[groovy_minor]
For example, the versions of GBench 0.4.3 that supports from Groovy 1.7
to Groovy 2.4 are:
0.4.3-groovy-1.7, 0.4.3-groovy-1.8, 0.4.3-groovy-2.0, 0.4.3-groovy-2.1,
0.4.3-groovy-2.2, 0.4.3-groovy-2.3, 0.4.3-groovy-2.4
DOWNLOADING
-----------
Download a distribution from the Maven Central repository using a
dependency manager of your choice.
Groovy Grape
@Grab(group='org.gperfutils', module='gbench', version='[version]')
Apache Maven
<dependency>
<groupId>org.gperfutils</groupId>
<artifactId>gbench</artifactId>
<version>[version]</version>
</dependency>
Apache Ivy
<dependency org="org.gperfutils" name="gbench" rev="[version]" />
BUILDING
--------
Build from source using Ant.
Distribution
ant dist -Dskip.test=true
Binary jar for a specific Groovy version
ant binary -Dgroovy.version=[groovy_version] -Dskip.test=true
EXAMPLES
--------
Compare the performance of StringBuilder and StringBuffer using Benchmark
Builder:
def r = benchmark { // or new groovyx.gbench.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()
}
}
r.prettyPrint()
/* stdout:
Environment
===========
* Groovy: 2.4.0
* JVM: Java HotSpot(TM) 64-Bit Server VM (24.75-b04, Oracle Corporation)
* JRE: 1.7.0_75
* Total Memory: 491.5 MB
* Maximum Memory: 910.5 MB
* OS: Mac OS X (10.10.1, x86_64)
Options
=======
* Warm Up: Auto (- 60 sec)
* CPU Time Measurement: On
user system cpu real
StringBuilder 115 0 115 117
StringBuffer 132 0 132 133
*/
Measure the execution time of a method using Benchmark Transformation:
import groovyx.gbench.Benchmark
class Task {
@Benchmark void run() {
// task
}
}
/* stdout:
Task void run() user:847000 system:1777000 cpu:2624000 real:4918000
*/
LICENSE
-------
GBench is licensed under the term of the Apache License, Version 2.0. See
the file LICENSE for the full license.