I Quit
After a few days of fixing SyntaxHighlighter on my blog, I finally decide to quit fixing it, rather I think I quit using blogger. Its hard to customize the style on my blog and its hard to add widget into my blog. I was forced to revert to 'classic template' which remove all my widgets. (Damn!)
Hmm... Maybe I should look into wordpress. Ok, watch out my next post for my new blog site.
Groovy Timer and Performance
Got a call from my good friend of mine mentioning groovy is slow in computation. Well, I had to agree with him that groovy might be slower than plain old Java classes. But i'm sure that will improve over time.
Our conversation start with him creating a simple script which loop 100,000 times performing simple mulitplication. He uses Linux for this test and it takes him around 2 min. I was surprise! Thus I did my own performance test with the follow script (Using tips from Groovy's Project Manager blog,
Timing a closure in Groovy :D)
timer = { closure ->
start = System.currentTimeMillis()
closure.call()
println System.currentTimeMillis() - start
}
// define an array with value 1 to 100000
def rates = 1..100000
println 'Performing 1st Test with .times'
timer {
def a = 10
def b = 2
100000.times {idx-> a*rates[idx] }
}
println 'Performing 2nd test with for'
timer {
def a = 10
def b = 2
for(int i=0;i<100000;i++) {
a*rates[i]
}
}
For the 1st test, it took 187ms on my window machine and 2nd test took 62ms. Phew... Anyway we are going to exchange information on our finding.
Labels: Groovy