import groovy.time.TimeCategory import groovy.time.TimeDuration def root= new File('/usr/share') def full= new File('/usr/share/docs/rpm-4.4') Date start = new Date() for (i in 1..10000){ def relPath= new File( root.toURI().relativize( full.toURI() ).toString() ) } Date stop = new Date() td = TimeCategory.minus( stop, start ) print ("Took: ${td}")