自动化你的测试(二)

2018-04-26  本文已影响0人  ww4u

问题

测试方法

生成点

def genRandom( lastXyz=(255,0,512) ):
    """
    gen a random (x,y,z) in cubicRange
    """
    distance = 0
    while( distance < 5 ):
        x = random.randint( cubicRange[0], cubicRange[1] )
        y = random.randint( cubicRange[2], cubicRange[3] )
        z = random.randint( cubicRange[4], cubicRange[5] )
        distance = spaceDistance( (x,y,z), lastXyz )
    return (x,y,z),distance
def spaceDistance( xyz1, xyz2 ):
    """
    calc the space distance (xyz1) -- (xyz2)
    """
    distance = 0
    for i in range( 0, 3 ):
        distance = math.pow( xyz1[i] - xyz2[i], 2 )
    return math.sqrt( distance )       

随机测试

xyz = ( 255,0,512)
    for i in range( 0, 100000 ):
        xyz, distance = genRandom( xyz )
        print ( "%g,%g,%g,%g" % ( xyz[0],xyz[1],xyz[2], distance ) )
        startTime = datetime.datetime.now()
        robo.goto( xyz[0],xyz[1],xyz[2], math.pow(distance,1/8) )
        print( ( datetime.datetime.now() - startTime).seconds )
上一篇 下一篇

猜你喜欢

热点阅读