From a2bd83a9a1a28f942b075a372653675355af086b Mon Sep 17 00:00:00 2001 From: mbs Date: Fri, 29 Sep 2023 10:49:18 +0100 Subject: [PATCH] bos#37844: SHAPER_Test1673.py random failures --- src/SketchPlugin/Test/Test1673.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/SketchPlugin/Test/Test1673.py b/src/SketchPlugin/Test/Test1673.py index d5b028a30..86d955ad0 100644 --- a/src/SketchPlugin/Test/Test1673.py +++ b/src/SketchPlugin/Test/Test1673.py @@ -28,6 +28,7 @@ import math # convenient ratio of time moving point to time creating sketch MOVE_BUILD_RATIO = 0.1 +NUM_MOVES = 50 # tolerance for comparison of reals TOLERANCE = 1.e-7 @@ -248,7 +249,7 @@ model.do() sketchTime = timer() - sketchTime print("Sketch creation time: {0}".format(sketchTime)) -expectedTime = MOVE_BUILD_RATIO * sketchTime +expectedTime = MOVE_BUILD_RATIO * sketchTime * NUM_MOVES averageTime = 0 nbMoves = 0 @@ -275,20 +276,21 @@ anAngle = math.pi / 100. aCos = math.cos(anAngle) aSin = math.sin(anAngle) -for ang in range(0, 50): +for ang in range(0, NUM_MOVES): movementTime = timer() X = aCenter.x() + aDeltaX * aCos + aDeltaY * aSin Y = aCenter.y() - aDeltaX * aSin + aDeltaY * aCos aEndPoint.setValue(X, Y) model.do() movementTime = timer() - movementTime - assert movementTime < expectedTime, "Time to move point {0} is greater than expected {1}".format(movementTime, expectedTime) assert math.fabs(aEndPoint.x() - X) < TOLERANCE and math.fabs(aEndPoint.y() - Y) < TOLERANCE, "({0}, {1}) != ({2}, {3})".format(aEndPoint.x(), aEndPoint.y(), X, Y) averageTime += movementTime nbMoves += 1 aDeltaX = aEndPoint.x() - aCenter.x() aDeltaY = aEndPoint.y() - aCenter.y() -print("Movement average time: {0}".format(averageTime / nbMoves)) +averageTime /= nbMoves +print("Movement average time: {0}".format(averageTime)) +assert averageTime < expectedTime, "Average time to move point {0} is greater than expected {1}".format(averageTime, expectedTime) model.end() -- 2.39.2