|
本帖最后由 爱电脑的昕宇 于 2022-8-8 12:17 编辑
再见!
备用EXE下载地址
源码:
# 初二暑假收官之作!
# 特别感谢@wdscxsj的指导!
# 爱电脑的昕宇
# 2022年8月8日 11:40:51
from time import *
from tkinter import *
from tkinter.ttk import *
from tkinter.messagebox import showinfo
def about():
showinfo('CPU Test', 'CPU Test V 2.0\n爱电脑的昕宇作品\n结果仅供参考。')
def main():
win.title('请稍候……')
looptime = 1
n = 0
total = 0
while total <= 5:
sta = time()
while n < (looptime * 1000000):
n = n + 1
t = time() - sta
total = total + t
looptime = looptime + 1
print(n)
print(total)
v = round(n / total)
win.title('CPU Test')
Label(win, text='变量为时间得分:' + str(v)).pack()
def mains():
win.title('请稍候……')
s = 0
t = time()
while s < 100000000:
s = s + 1
v = round(s / (time() - t))
win.title('CPU Test')
Label(win, text='变量为次数得分:' + str(v)).pack()
def helpinfo(event):
win1 = Tk()
win1.resizable(0, 0)
win1.title('这是什么?')
Label(win1, text='帮助\n\n在控制变量为时间测试中,程序进行5秒的循环测试,每次测试执行一百万次+1运算;\n\n在控制变量为次数测试中,程序执行一亿次+1运算,直到运算完成后计算速度。',
font=("微软雅黑", 12)).pack()
win.mainloop()
win = Tk()
win.resizable(0, 0)
win.minsize(200, 50)
win.title('CPU Test')
menu1 = Menu(win)
menu1.add_command(label='关于', command=lambda: about())
win.config(menu=menu1)
Button(win, text='控制变量为时间测试', command=lambda: main()).pack()
Button(win, text='控制变量为次数测试', command=lambda: mains()).pack()
Help = Label(win, text='这是什么?', font=("微软雅黑", 8, "underline"), foreground='blue')
Help.bind("<Button-1>", helpinfo)
Help.pack()
win.mainloop()
|
-
-
CT.py
1.97 KB, 下载次数: 314
2.0
-
-
CT.zip
7.78 MB, 下载次数: 394
EXE
|