Posted By

berndschiffer on 08/07/09


Tagged

textmate groovy closureexample


Versions (?)

Stefans Lösung


 / Published in: Groovy
 

URL: http://berndschiffer.blogspot.com/2009/08/beispiel-fur-refactoring-von-beispiel.html

  1. def timeLogged (Closure c) {
  2. long start = - System.currentTimeMillis()
  3. c.call()
  4. println "duration in sec: " + (System.currentTimeMillis() + start) / 1000;
  5. }
  6.  
  7. def tueA() { tue('a') }
  8. def tueB() { tue('b') }
  9. def tueC() { tue('c') }
  10.  
  11. def tue(was) {
  12. println was
  13. sleep(100)
  14. }
  15.  
  16. timeLogged { tueA() }
  17. timeLogged { tueB() }
  18. timeLogged { tueC() }

Report this snippet  

You need to login to post a comment.