groovycode.com

Calculate elapsed time in Groovy

To time the excution use the following snippet

1 import groovy.time.TimeCategory 
2 import groovy.time.TimeDuration
3 
4 Date start = new Date()
5 // do something here
6 Date stop = new Date()
7 
8 TimeDuration td = TimeCategory.minus( stop, start )
9 println td

The result should be:

0.001 seconds

tags: io time