From 9ba33cb09d684eb5b5ea10379e801ebc7de135ba Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 13 May 2013 18:52:19 +0200 Subject: First tiny bit of statistics. --- src/dotty/tools/dotc/core/Trees.scala | 6 ++++++ src/dotty/tools/dotc/util/Stats.scala | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 src/dotty/tools/dotc/util/Stats.scala diff --git a/src/dotty/tools/dotc/core/Trees.scala b/src/dotty/tools/dotc/core/Trees.scala index 3e09eafb7..054b17fa9 100644 --- a/src/dotty/tools/dotc/core/Trees.scala +++ b/src/dotty/tools/dotc/core/Trees.scala @@ -8,6 +8,7 @@ import language.higherKinds import collection.mutable import collection.mutable.ArrayBuffer import parsing.Tokens.Token +import util.Stats object Trees { @@ -21,6 +22,9 @@ object Trees { type TypedTree = Tree[Type] type UntypedTree = Tree[Untyped] + /** The total number of created tree nodes, maintained if Stats.enabled */ + var ntrees = 0 + /** A base class for things that have positions (currently: modifiers and trees) */ abstract class Positioned extends DotClass with Product { @@ -133,6 +137,8 @@ object Trees { */ abstract class Tree[T >: Untyped] extends Positioned with Product with Showable with Cloneable { + if (Stats.enabled) ntrees += 1 + /** The type constructor at the root of the tree */ type ThisTree[T >: Untyped] <: Tree[T] diff --git a/src/dotty/tools/dotc/util/Stats.scala b/src/dotty/tools/dotc/util/Stats.scala new file mode 100644 index 000000000..68884fdbc --- /dev/null +++ b/src/dotty/tools/dotc/util/Stats.scala @@ -0,0 +1,7 @@ +package dotty.tools.dotc.util + +object Stats { + + final val enabled = true + +} \ No newline at end of file -- cgit v1.2.3