为什么def的yi函数统计出的sort的耗时和之前运行的结果不一样,要怎么把之前的运行结果,def一个函数来进行统计,以及绘制折线图的报错要怎样修改
你的 count_time函数返回的result是一个拷贝数组,不是运行时间,将其改为即可返回时间
return round(end_time - start_time,6)
屏蔽
# plt.legend(Sort = 'best')
count_time函数的返回结果应该是计算运行的时长。
def count_time(sort,array):
start_time=time.perf_counter()
result=sorted(array.copy())
end_time=time.perf_counter()
c_time=round(end_time-start_time,6)
return c_time
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!