diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-14 23:04:49 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-19 21:13:49 -0400 |
commit | 35a96fea9336dfcac8aac75824450cbf7dc4ae1a (patch) | |
tree | 0c363f0c04f55ddb78463dc68f5e6a84291b970b /stage1/PoorMansProfiler.scala | |
parent | 2b19be1993439d1deb48a222c0985d436e463f44 (diff) | |
download | cbt-35a96fea9336dfcac8aac75824450cbf7dc4ae1a.tar.gz cbt-35a96fea9336dfcac8aac75824450cbf7dc4ae1a.tar.bz2 cbt-35a96fea9336dfcac8aac75824450cbf7dc4ae1a.zip |
add a time keeping facility for debugging
Diffstat (limited to 'stage1/PoorMansProfiler.scala')
-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 |