Created
April 26, 2013 17:44
-
-
Save jonatasemidio/5469008 to your computer and use it in GitHub Desktop.
Desempenho em calculos matemáticos com groovy. Resultado do Calculo: http://groovyconsole.appspot.com/script/953001
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Ainda não sei em detalhes o motivio, mas por acaso percebi que tenho uma | |
//resposta mais rápida quando executo operações matemáticas utilizando os métodos fornecidos pelo Number em questão | |
def start1 = System.nanoTime() | |
100.times{ 150.div(3) } | |
def stop1 = System.nanoTime() | |
println "150.div(3) : "+stop1 - start1 | |
def start2 = System.nanoTime() | |
100.times{ 150/3 } | |
def stop2 = System.nanoTime() | |
println "150/3 : "+stop2 - start2 | |
println '--------------------------------' | |
def start11 = System.nanoTime() | |
100.times{ 150.intdiv(3) } | |
def stop11 = System.nanoTime() | |
println "150.intdiv(3) : "+stop11 - start11 | |
def start21 = System.nanoTime() | |
100.times{ (int)150/3 } | |
def stop21 = System.nanoTime() | |
println "(int)150/3 : "+stop21 - start21 | |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment