diff options
Diffstat (limited to 'stage1')
-rw-r--r-- | stage1/PoorMansProfiler.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/stage1/PoorMansProfiler.scala b/stage1/PoorMansProfiler.scala new file mode 100644 index 0000000..b7aa47d --- /dev/null +++ b/stage1/PoorMansProfiler.scala @@ -0,0 +1,23 @@ +/* +// temporary debugging tool +package cbt +import java.util.concurrent.ConcurrentHashMap +import collection.JavaConversions._ +object PoorMansProfiler{ + val entries = new ConcurrentHashMap[String, Long] + def profile[T](name: String)(code: => T): T = { + val before = System.currentTimeMillis + if(!(entries containsKey name)){ + entries.put( name, 0 ) + } + val res = code + entries.put( name, (entries get name) + (System.currentTimeMillis - before) ) + res + } + def summary: String = { + "Profiling Summary:\n" + entries.toSeq.sortBy(_._2).map{ + case (name, value) => name + ": " + (value / 1000.0) + }.mkString("\n") + } +} +*/
\ No newline at end of file |