(n)
| 178 | impl = getDOMImplementation() |
| 179 | |
| 180 | def work(n): |
| 181 | doc = impl.createDocument(None, "some_tag", None) |
| 182 | element = doc.documentElement |
| 183 | total_calls = 0 |
| 184 | |
| 185 | # Count attribute accesses as a proxy for work done |
| 186 | def getattribute_counter(self, attr): |
| 187 | nonlocal total_calls |
| 188 | total_calls += 1 |
| 189 | return object.__getattribute__(self, attr) |
| 190 | |
| 191 | with support.swap_attr(Element, "__getattribute__", getattribute_counter): |
| 192 | for _ in range(n): |
| 193 | child = doc.createElement("child") |
| 194 | element.appendChild(child) |
| 195 | element = child |
| 196 | return total_calls |
| 197 | |
| 198 | # Doubling N should not ~quadruple the work. |
| 199 | w1 = work(1024) |
nothing calls this directly
no test coverage detected