From 2eeda7ef5302aefc4f40703dde331799a0277db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E7=91=97=E6=9D=B0?= <3695888@qq.com> Date: Sun, 31 Oct 2021 14:58:09 +0800 Subject: [PATCH] 0.6.1 developing --- Difficult_Rocket.py | 2 +- Difficult_Rocket/command/command.py | 1 - Difficult_Rocket/crash/__init__.py | 7 ++++ Difficult_Rocket/{ => crash}/crash.py | 0 tests/sort_speed_check.py | 57 +++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) rename Difficult_Rocket/{ => crash}/crash.py (100%) create mode 100644 tests/sort_speed_check.py diff --git a/Difficult_Rocket.py b/Difficult_Rocket.py index 881f08d..606db1a 100644 --- a/Difficult_Rocket.py +++ b/Difficult_Rocket.py @@ -41,7 +41,7 @@ if __name__ == '__main__': from Difficult_Rocket.api.Exp import * try: - from Difficult_Rocket import crash + from Difficult_Rocket.crash import crash from Difficult_Rocket import main game = main.Game() diff --git a/Difficult_Rocket/command/command.py b/Difficult_Rocket/command/command.py index 90a2eec..f2d31c2 100644 --- a/Difficult_Rocket/command/command.py +++ b/Difficult_Rocket/command/command.py @@ -175,7 +175,6 @@ class CommandLine(widgets.WidgetBase): self._label[now].opacity = 255 if not self.editing: # 如果不在编辑再隐藏 self._label[0].visible = False - print(self._label[0].opacity) """ events diff --git a/Difficult_Rocket/crash/__init__.py b/Difficult_Rocket/crash/__init__.py index 80dcc9a..2d580af 100644 --- a/Difficult_Rocket/crash/__init__.py +++ b/Difficult_Rocket/crash/__init__.py @@ -10,3 +10,10 @@ mail: 3695888@qq.com github: @shenjackyuanjie gitee: @shenjackyuanjie """ + +from .crash import * + + +__all__ = ['all_thread', + 'all_process', + 'crash'] diff --git a/Difficult_Rocket/crash.py b/Difficult_Rocket/crash/crash.py similarity index 100% rename from Difficult_Rocket/crash.py rename to Difficult_Rocket/crash/crash.py diff --git a/tests/sort_speed_check.py b/tests/sort_speed_check.py new file mode 100644 index 0000000..07a7943 --- /dev/null +++ b/tests/sort_speed_check.py @@ -0,0 +1,57 @@ +import time +import random + + +# 生成一个以纳秒为单位自动计时输入函数的耗时并以纳秒和秒为单位输出时长的装饰器 +def time_measure(func): + def wrapper(*args, **kwargs): + t1 = time.perf_counter_ns() + func(*args, **kwargs) + t2 = time.perf_counter_ns() + # print('{} took {} seconds'.format(func.__name__, t2 - t1)) + print('{} took {} nanoseconds'.format(func.__name__, (t2 - t1) / 1000000000)) + return func(*args, **kwargs) + return wrapper + + +# 一个长度为十万的整数列表 +nums = [random.randint(0, 1000000) for _ in range(1000000)] +test_list = [random.random() for _ in range(1000000)] + + +# 排序test_list并计时 +@time_measure +def sort_test(): + test_list.sort() + + +@time_measure +def sortit(): + nums.sort() + +sortit() +sort_test() + +# 运行10次sort_test和sortit,并计算平均时间 +for _ in range(10): + sort_test() + +for _ in range(10): + sortit() + + +# 使用pyglet创建一个窗口,并在窗口中绘制一个线条 +from libs import pyglet +window = pyglet.window.Window(width=500, height=500) +vertices = (0, 0, 0, 500, 500, 500, 500, 0) +colors = (255, 0, 0, 255, 0, 255, 255, 255) +batch = pyglet.graphics.Batch() +batch.add(4, pyglet.gl.GL_QUADS, None, ('v2i', vertices), ('c3B', colors)) + + + + +# sortit took 144131100 seconds +# sortit took 0.1441311 nanoseconds +# sort_test took 146132900 seconds +# sort_test took 0.1461329 nanoseconds