我有这个密码:
for times in range(50):
factor = (min(getHeight(),getWidth()) / math.sqrt(qtdPosicoes)) * guess()
positionInGrid = {}
grid = np.zeros((getGridColumns(),getGridLines()))
groupMatrix = np.zeros((grid.shape[0], grid.shape[1]))
groups = getGroups(grid, listaComPosicoes, getXRanges(listaComPosicoes),getYRanges(listaComPosicoes))
solution = calculaSilhueta()
if bestSolution is None or solution > bestSolution:
bestSolution = solution
我在文档时间模块中找到,但不知道如何使用
使用此模块的一个简单方法是让
time.time()
标记代码的开头,然后再次使用time.time()
标记代码的结尾。在那之后,减去它们,这样你就可以得到持续时间。所以你的代码应该是:
示例:
但更好的选择是使用
timeit
模块,这更容易:希望这有帮助!
一个简单的解决方案是
相关问题 更多 >
编程相关推荐