A builder for micro-benchmarking.
This builder allows accurate and easy benchmark.
For example, you can benchmark character concatenation using
StringBuilder and StringBuffer and compare their
performances like the following:
def bm = 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()
}
}
bm.prettyPrint()
then means (in nanoseconds) of each execution time will be printed out:
user system cpu real
StringBuilder 283 0 284 286
StringBuffer 319 0 319 321
| Modifiers | Name | Description |
|---|---|---|
static int |
AUTO |
| Type | Name and description |
|---|---|
BenchmarkList |
benchmarks |
Gets benchmarks.
options
- false.
false.
clos - a closure to add code blocks for benchmarking.