Commit 6723dd37 by Aaron Leung

Counting heap-allocated vectors.

parent ef5be943
...@@ -14,6 +14,7 @@ using std::endl; ...@@ -14,6 +14,7 @@ using std::endl;
namespace Sass { namespace Sass {
size_t Node::fresh = 0; size_t Node::fresh = 0;
size_t Node::copied = 0; size_t Node::copied = 0;
size_t Node::allocations = 0;
Node Node::clone() const Node Node::clone() const
{ {
......
...@@ -75,6 +75,7 @@ namespace Sass { ...@@ -75,6 +75,7 @@ namespace Sass {
static size_t fresh; static size_t fresh;
static size_t copied; static size_t copied;
static size_t allocations;
size_t line_number; size_t line_number;
mutable vector<Node>* children; mutable vector<Node>* children;
...@@ -128,7 +129,7 @@ namespace Sass { ...@@ -128,7 +129,7 @@ namespace Sass {
has_backref(false), has_backref(false),
from_variable(false), from_variable(false),
eval_me(false) eval_me(false)
{ children->reserve(length); ++fresh; } { children->reserve(length); ++fresh; ++allocations; }
Node(size_t line_number, Type type, const Node& n) Node(size_t line_number, Type type, const Node& n)
: line_number(line_number), : line_number(line_number),
...@@ -143,7 +144,7 @@ namespace Sass { ...@@ -143,7 +144,7 @@ namespace Sass {
has_backref(false), has_backref(false),
from_variable(false), from_variable(false),
eval_me(false) eval_me(false)
{ ++fresh; } { ++fresh; ++allocations; }
Node(size_t line_number, Type type, const Node& n, const Node& m) Node(size_t line_number, Type type, const Node& n, const Node& m)
: line_number(line_number), : line_number(line_number),
...@@ -163,6 +164,7 @@ namespace Sass { ...@@ -163,6 +164,7 @@ namespace Sass {
children->push_back(n); children->push_back(n);
children->push_back(m); children->push_back(m);
++fresh; ++fresh;
++allocations;
} }
Node(size_t line_number, Type type, Token& token) Node(size_t line_number, Type type, Token& token)
...@@ -229,6 +231,7 @@ namespace Sass { ...@@ -229,6 +231,7 @@ namespace Sass {
children->push_back(Node(line_number, b)); children->push_back(Node(line_number, b));
children->push_back(Node(line_number, c)); children->push_back(Node(line_number, c));
++fresh; ++fresh;
++allocations;
} }
//~Node() { delete children; } //~Node() { delete children; }
......
...@@ -36,7 +36,7 @@ int main(int argc, char* argv[]) { ...@@ -36,7 +36,7 @@ int main(int argc, char* argv[]) {
cerr << "Fresh nodes:\t" << Node::fresh << endl; cerr << "Fresh nodes:\t" << Node::fresh << endl;
cerr << "Copied nodes:\t" << Node::copied << endl; cerr << "Copied nodes:\t" << Node::copied << endl;
cerr << "Allocations:\t" << Node::allocations << endl;
cout << output; cout << output;
return 0; 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