mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
gh-142145: relax the no-longer-quadratic test timing (#143030)
* gh-142145: relax the no-longer-quadratic test timing * require cpu resource
This commit is contained in:
parent
2b4feee648
commit
8d2d7bb2e7
1 changed files with 8 additions and 3 deletions
|
|
@ -174,6 +174,7 @@ def testAppendChild(self):
|
||||||
self.assertEqual(dom.documentElement.childNodes[-1].data, "Hello")
|
self.assertEqual(dom.documentElement.childNodes[-1].data, "Hello")
|
||||||
dom.unlink()
|
dom.unlink()
|
||||||
|
|
||||||
|
@support.requires_resource('cpu')
|
||||||
def testAppendChildNoQuadraticComplexity(self):
|
def testAppendChildNoQuadraticComplexity(self):
|
||||||
impl = getDOMImplementation()
|
impl = getDOMImplementation()
|
||||||
|
|
||||||
|
|
@ -182,14 +183,18 @@ def testAppendChildNoQuadraticComplexity(self):
|
||||||
children = [newdoc.createElement(f"child-{i}") for i in range(1, 2 ** 15 + 1)]
|
children = [newdoc.createElement(f"child-{i}") for i in range(1, 2 ** 15 + 1)]
|
||||||
element = top_element
|
element = top_element
|
||||||
|
|
||||||
start = time.time()
|
start = time.monotonic()
|
||||||
for child in children:
|
for child in children:
|
||||||
element.appendChild(child)
|
element.appendChild(child)
|
||||||
element = child
|
element = child
|
||||||
end = time.time()
|
end = time.monotonic()
|
||||||
|
|
||||||
# This example used to take at least 30 seconds.
|
# This example used to take at least 30 seconds.
|
||||||
self.assertLess(end - start, 1)
|
# Conservative assertion due to the wide variety of systems and
|
||||||
|
# build configs timing based tests wind up run under.
|
||||||
|
# A --with-address-sanitizer --with-pydebug build on a rpi5 still
|
||||||
|
# completes this loop in <0.5 seconds.
|
||||||
|
self.assertLess(end - start, 4)
|
||||||
|
|
||||||
def testSetAttributeNodeWithoutOwnerDocument(self):
|
def testSetAttributeNodeWithoutOwnerDocument(self):
|
||||||
# regression test for gh-142754
|
# regression test for gh-142754
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue