本文整理汇总了Python中timer.Timer.time_left方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.time_left方法的具体用法?Python Timer.time_left怎么用?Python Timer.time_left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.time_left方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: solve
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import time_left [as 别名]
def solve(self, presents_to_place):
if self.make_timer:
timer = Timer()
num_total_presents = len(presents_to_place)
gc_collect_count = 0
presents_index = 0
presents_last_index = len(presents_to_place)
while 1:
priority_pick = self.priority_pick
new_layer = MaxRectSolver(self.width, self.height)
try:
presents_index = new_layer.solve(presents_to_place, presents_index, self.scorer, priority_pick)
self._add_layer(new_layer)
print("{} more presents".format(presents_last_index - presents_index))
if presents_index == presents_last_index - 1:
break
except NoFit:
priority_pick -= 10
assert priority_pick > 1
if self.make_timer:
ratio = presents_index / num_total_presents
print("Time left: {}; End time: {}".format(timer.time_left(ratio), timer.time_end(ratio)))
print("Solved with total depth {}".format(self.total_depth))
if self.make_timer:
print("Time taken: {}".format(timer.time_taken()))
if self.gc_collect_cycle:
gc_collect_count += 1
if gc_collect_count == self.gc_collect_cycle:
gc_collect_count = 0
print("GC collect")
gc.collect()