Skip to content

Instantly share code, notes, and snippets.

@jonatasemidio
Created May 29, 2015 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonatasemidio/14ad2dbdf0aa05bf5a44 to your computer and use it in GitHub Desktop.
Save jonatasemidio/14ad2dbdf0aa05bf5a44 to your computer and use it in GitHub Desktop.
What is my mistake?
@Grab( 'com.googlecode.gbench:gbench:0.3.0-groovy-2.0' )
import gbench.*
def i = 0
new BenchmarkBuilder().run( measureCpuTime:true ) {
'TEST:' {
1000000.times{i?.toLong() ? i?.toLong() : null}
}
'TEST:' {
1000000.times{i?.toLong() ? i?.toLong() : null}
}
}.prettyPrint()
/**
Me: Why Do I have a different result for the same code?
Environment
===========
* Groovy: 2.4.0
* JVM: Java HotSpot(TM) 64-Bit Server VM (21.0-b17, Oracle Corporation)
* JRE: 1.7.0
* Total Memory: 127 MB
* Maximum Memory: 127 MB
* OS: Windows 7 (6.1, amd64)
Options
=======
* Warm Up: Auto
* CPU Time Measurement: On
user system cpu real
TEST: 134550862 0 134550862 133996441
TEST: 140400900 0 140400900 140462451
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment