Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: Source/core/dom/Node.cpp

Issue 310433002: Dust off and fix DUMP_NODE_STATISTICS (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 void Node::operator delete(void* ptr) 112 void Node::operator delete(void* ptr)
113 { 113 {
114 ASSERT(isMainThread()); 114 ASSERT(isMainThread());
115 partitionFree(ptr); 115 partitionFree(ptr);
116 } 116 }
117 #endif 117 #endif
118 118
119 #if DUMP_NODE_STATISTICS 119 #if DUMP_NODE_STATISTICS
120 static HashSet<Node*> liveNodeSet; 120 static HashSet<Node*>& liveNodeSet()
121 {
122 DEFINE_STATIC_LOCAL(HashSet<Node*>, s_liveNodeSet, ());
123 return s_liveNodeSet;
124 }
121 #endif 125 #endif
122 126
123 void Node::dumpStatistics() 127 void Node::dumpStatistics()
124 { 128 {
125 #if DUMP_NODE_STATISTICS 129 #if DUMP_NODE_STATISTICS
126 size_t nodesWithRareData = 0; 130 size_t nodesWithRareData = 0;
127 131
128 size_t elementNodes = 0; 132 size_t elementNodes = 0;
129 size_t attrNodes = 0; 133 size_t attrNodes = 0;
130 size_t textNodes = 0; 134 size_t textNodes = 0;
131 size_t cdataNodes = 0; 135 size_t cdataNodes = 0;
132 size_t commentNodes = 0; 136 size_t commentNodes = 0;
133 size_t piNodes = 0; 137 size_t piNodes = 0;
134 size_t documentNodes = 0; 138 size_t documentNodes = 0;
135 size_t docTypeNodes = 0; 139 size_t docTypeNodes = 0;
136 size_t fragmentNodes = 0; 140 size_t fragmentNodes = 0;
137 size_t shadowRootNodes = 0; 141 size_t shadowRootNodes = 0;
138 142
139 HashMap<String, size_t> perTagCount; 143 HashMap<String, size_t> perTagCount;
140 144
141 size_t attributes = 0; 145 size_t attributes = 0;
142 size_t attributesWithAttr = 0;
143 size_t elementsWithAttributeStorage = 0; 146 size_t elementsWithAttributeStorage = 0;
144 size_t elementsWithRareData = 0; 147 size_t elementsWithRareData = 0;
145 size_t elementsWithNamedNodeMap = 0; 148 size_t elementsWithNamedNodeMap = 0;
146 149
147 for (HashSet<Node*>::iterator it = liveNodeSet.begin(); it != liveNodeSet.en d(); ++it) { 150 for (HashSet<Node*>::iterator it = liveNodeSet().begin(); it != liveNodeSet( ).end(); ++it) {
148 Node* node = *it; 151 Node* node = *it;
149 152
150 if (node->hasRareData()) { 153 if (node->hasRareData()) {
151 ++nodesWithRareData; 154 ++nodesWithRareData;
152 if (node->isElementNode()) { 155 if (node->isElementNode()) {
153 ++elementsWithRareData; 156 ++elementsWithRareData;
154 if (toElement(node)->hasNamedNodeMap()) 157 if (toElement(node)->hasNamedNodeMap())
155 ++elementsWithNamedNodeMap; 158 ++elementsWithNamedNodeMap;
156 } 159 }
157 } 160 }
158 161
159 switch (node->nodeType()) { 162 switch (node->nodeType()) {
160 case ELEMENT_NODE: { 163 case ELEMENT_NODE: {
161 ++elementNodes; 164 ++elementNodes;
162 165
163 // Tag stats 166 // Tag stats
164 Element* element = toElement(node); 167 Element* element = toElement(node);
165 HashMap<String, size_t>::AddResult result = perTagCount.add(elem ent->tagName(), 1); 168 HashMap<String, size_t>::AddResult result = perTagCount.add(elem ent->tagName(), 1);
166 if (!result.isNewEntry) 169 if (!result.isNewEntry)
167 result.storedValue->value++; 170 result.storedValue->value++;
168 171
169 if (ElementData* elementData = element->elementData()) { 172 if (const ElementData* elementData = element->elementData()) {
170 attributes += elementData->length(); 173 attributes += elementData->length();
171 ++elementsWithAttributeStorage; 174 ++elementsWithAttributeStorage;
172 for (unsigned i = 0; i < elementData->length(); ++i) {
173 Attribute* attr = elementData->attributeItem(i);
174 if (attr->attr())
175 ++attributesWithAttr;
176 }
177 } 175 }
178 break; 176 break;
179 } 177 }
180 case ATTRIBUTE_NODE: { 178 case ATTRIBUTE_NODE: {
181 ++attrNodes; 179 ++attrNodes;
182 break; 180 break;
183 } 181 }
184 case TEXT_NODE: { 182 case TEXT_NODE: {
185 ++textNodes; 183 ++textNodes;
186 break; 184 break;
(...skipping 21 matching lines...) Expand all
208 case DOCUMENT_FRAGMENT_NODE: { 206 case DOCUMENT_FRAGMENT_NODE: {
209 if (node->isShadowRoot()) 207 if (node->isShadowRoot())
210 ++shadowRootNodes; 208 ++shadowRootNodes;
211 else 209 else
212 ++fragmentNodes; 210 ++fragmentNodes;
213 break; 211 break;
214 } 212 }
215 } 213 }
216 } 214 }
217 215
218 printf("Number of Nodes: %d\n\n", liveNodeSet.size()); 216 printf("Number of Nodes: %d\n\n", liveNodeSet().size());
219 printf("Number of Nodes with RareData: %zu\n\n", nodesWithRareData); 217 printf("Number of Nodes with RareData: %zu\n\n", nodesWithRareData);
220 218
221 printf("NodeType distribution:\n"); 219 printf("NodeType distribution:\n");
222 printf(" Number of Element nodes: %zu\n", elementNodes); 220 printf(" Number of Element nodes: %zu\n", elementNodes);
223 printf(" Number of Attribute nodes: %zu\n", attrNodes); 221 printf(" Number of Attribute nodes: %zu\n", attrNodes);
224 printf(" Number of Text nodes: %zu\n", textNodes); 222 printf(" Number of Text nodes: %zu\n", textNodes);
225 printf(" Number of CDATASection nodes: %zu\n", cdataNodes); 223 printf(" Number of CDATASection nodes: %zu\n", cdataNodes);
226 printf(" Number of Comment nodes: %zu\n", commentNodes); 224 printf(" Number of Comment nodes: %zu\n", commentNodes);
227 printf(" Number of ProcessingInstruction nodes: %zu\n", piNodes); 225 printf(" Number of ProcessingInstruction nodes: %zu\n", piNodes);
228 printf(" Number of Document nodes: %zu\n", documentNodes); 226 printf(" Number of Document nodes: %zu\n", documentNodes);
229 printf(" Number of DocumentType nodes: %zu\n", docTypeNodes); 227 printf(" Number of DocumentType nodes: %zu\n", docTypeNodes);
230 printf(" Number of DocumentFragment nodes: %zu\n", fragmentNodes); 228 printf(" Number of DocumentFragment nodes: %zu\n", fragmentNodes);
231 printf(" Number of ShadowRoot nodes: %zu\n", shadowRootNodes); 229 printf(" Number of ShadowRoot nodes: %zu\n", shadowRootNodes);
232 230
233 printf("Element tag name distibution:\n"); 231 printf("Element tag name distibution:\n");
234 for (HashMap<String, size_t>::iterator it = perTagCount.begin(); it != perTa gCount.end(); ++it) 232 for (HashMap<String, size_t>::iterator it = perTagCount.begin(); it != perTa gCount.end(); ++it)
235 printf(" Number of <%s> tags: %zu\n", it->key.utf8().data(), it->value) ; 233 printf(" Number of <%s> tags: %zu\n", it->key.utf8().data(), it->value) ;
236 234
237 printf("Attributes:\n"); 235 printf("Attributes:\n");
238 printf(" Number of Attributes (non-Node and Node): %zu [%zu]\n", attributes , sizeof(Attribute)); 236 printf(" Number of Attributes (non-Node and Node): %zu [%zu]\n", attributes , sizeof(Attribute));
239 printf(" Number of Attributes with an Attr: %zu\n", attributesWithAttr);
240 printf(" Number of Elements with attribute storage: %zu [%zu]\n", elementsW ithAttributeStorage, sizeof(ElementData)); 237 printf(" Number of Elements with attribute storage: %zu [%zu]\n", elementsW ithAttributeStorage, sizeof(ElementData));
241 printf(" Number of Elements with RareData: %zu\n", elementsWithRareData); 238 printf(" Number of Elements with RareData: %zu\n", elementsWithRareData);
242 printf(" Number of Elements with NamedNodeMap: %zu [%zu]\n", elementsWithNa medNodeMap, sizeof(NamedNodeMap)); 239 printf(" Number of Elements with NamedNodeMap: %zu [%zu]\n", elementsWithNa medNodeMap, sizeof(NamedNodeMap));
243 #endif 240 #endif
244 } 241 }
245 242
246 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, nodeCounter, ("WebCoreNode" )); 243 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, nodeCounter, ("WebCoreNode" ));
247 244
248 void Node::trackForDebugging() 245 void Node::trackForDebugging()
249 { 246 {
250 #ifndef NDEBUG 247 #ifndef NDEBUG
251 nodeCounter.increment(); 248 nodeCounter.increment();
252 #endif 249 #endif
253 250
254 #if DUMP_NODE_STATISTICS 251 #if DUMP_NODE_STATISTICS
255 liveNodeSet.add(this); 252 liveNodeSet().add(this);
256 #endif 253 #endif
257 } 254 }
258 255
259 Node::~Node() 256 Node::~Node()
260 { 257 {
261 #ifndef NDEBUG 258 #ifndef NDEBUG
262 nodeCounter.decrement(); 259 nodeCounter.decrement();
263 #endif 260 #endif
264 261
265 #if DUMP_NODE_STATISTICS 262 #if DUMP_NODE_STATISTICS
266 liveNodeSet.remove(this); 263 liveNodeSet().remove(this);
267 #endif 264 #endif
268 265
269 #if !ENABLE(OILPAN) 266 #if !ENABLE(OILPAN)
270 if (hasRareData()) 267 if (hasRareData())
271 clearRareData(); 268 clearRareData();
272 269
273 RELEASE_ASSERT(!renderer()); 270 RELEASE_ASSERT(!renderer());
274 271
275 if (!isContainerNode()) 272 if (!isContainerNode())
276 willBeDeletedFromDocument(); 273 willBeDeletedFromDocument();
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 node->showTreeForThis(); 2575 node->showTreeForThis();
2579 } 2576 }
2580 2577
2581 void showNodePath(const WebCore::Node* node) 2578 void showNodePath(const WebCore::Node* node)
2582 { 2579 {
2583 if (node) 2580 if (node)
2584 node->showNodePathForThis(); 2581 node->showNodePathForThis();
2585 } 2582 }
2586 2583
2587 #endif 2584 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698