CanMV离线运行print要20ms

Viewed 71

软硬件版本信息
庐山派 1.2.2

补充材料
具体内容我放在下面回答里,提问老是发不出去

1 Answers

只是 print('123') 这语句,在IDE中运行很快,但保存 main.py 自动运行,却要20ms

测试代码如下,把计时结果显示到LCD屏幕上

import time, os, urandom, sys
from media.display import *
from media.media import *

# 3.1寸屏幕模式
DISPLAY_WIDTH = 800
DISPLAY_HEIGHT = 480

os.exitpoint(os.EXITPOINT_ENABLE)
img = image.Image(DISPLAY_WIDTH, DISPLAY_HEIGHT, image.ARGB8888)
Display.init(Display.ST7701, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT, to_ide=True)
MediaManager.init()
try:
    while True:
        img.clear()

        start=time.ticks_ms()
        print('123')
        stop=time.ticks_ms()

        img.draw_string_advanced(50,50,32, f"{stop-start}",)
        Display.show_image(img)

        time.sleep(1)  # 暂停1秒
        os.exitpoint()  # 可用的退出点

except KeyboardInterrupt as e:
    print("用户终止:", e)  # 捕获键盘中断异常
except BaseException as e:
    print(f"异常:{e}")  # 捕获其他异常
finally:
    # 清理资源
    Display.deinit()
    os.exitpoint(os.EXITPOINT_ENABLE_SLEEP)  # 启用睡眠模式的退出点
    time.sleep_ms(100)  # 延迟100毫秒
    MediaManager.deinit()