Commit 6723dd37 by Aaron Leung

Counting heap-allocated vectors.

parent ef5be943
......@@ -14,6 +14,7 @@ using std::endl;
namespace Sass {
size_t Node::fresh = 0;
size_t Node::copied = 0;
size_t Node::allocations = 0;
Node Node::clone() const
{
......
......@@ -75,6 +75,7 @@ namespace Sass {
static size_t fresh;
static size_t copied;
static size_t allocations;
size_t line_number;
mutable vector<Node>* children;
......@@ -128,7 +129,7 @@ namespace Sass {
has_backref(false),
from_variable(false),
eval_me(false)
{ children->reserve(length); ++fresh; }
{ children->reserve(length); ++fresh; ++allocations; }
Node(size_t line_number, Type type, const Node& n)
: line_number(line_number),
......@@ -143,7 +144,7 @@ namespace Sass {
has_backref(false),
from_variable(false),
eval_me(false)
{ ++fresh; }
{ ++fresh; ++allocations; }
Node(size_t line_number, Type type, const Node& n, const Node& m)
: line_number(line_number),
......@@ -163,6 +164,7 @@ namespace Sass {
children->push_back(n);
children->push_back(m);
++fresh;
++allocations;
}
Node(size_t line_number, Type type, Token& token)
......@@ -229,6 +231,7 @@ namespace Sass {
children->push_back(Node(line_number, b));
children->push_back(Node(line_number, c));
++fresh;
++allocations;
}
//~Node() { delete children; }
......
......@@ -36,7 +36,7 @@ int main(int argc, char* argv[]) {
cerr << "Fresh nodes:\t" << Node::fresh << endl;
cerr << "Copied nodes:\t" << Node::copied << endl;
cerr << "Allocations:\t" << Node::allocations << endl;
cout << output;
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment