我在Python中有一个命令行程序需要一段时间才能完成.我想知道完成跑步所需的确切时间.
我看过这个timeit模块,但它似乎只适用于小代码片段.我想要整个计划的时间.
我理解的是什么timeit,但我不知道如何在我的代码中实现它.
我如何比较两个功能,说insertion_sort和tim_sort,用timeit?
我正在制作一个代码模拟一个围绕垄断板的棋子一百万次.我希望有一个tqdm进度条,每次转盘时都会更新.
以下是我目前的代码.我正在使用while循环,当电路板周围的转数超过所需数量时,它会停止.
import os
from openpyxl import Workbook
from monopolyfct import *
def main(runs, fileOutput):
### EXCEL SETUP ###
theWorkbook = Workbook() # Creates the workbook interface.
defaultSheet = theWorkbook.active # Creates the used worksheet.
currentData = ["Current Table Turn", "Current Tile"] # Makes EXCEL column titles.
defaultSheet.append(currentData) # Appends column titles.
### CONTENT SETUP ###
currentData = [1, 0] # Sets starting position.
defaultSheet.append(currentData) # Appends starting position.
while currentData[0] <= runs:
### ROLLING THE DICES PROCESS ### …Run Code Online (Sandbox Code Playgroud)