You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何提升VS Code Jupyter Notebook运行时长指示器的精度?

提升VS Code Jupyter Notebook单元格运行时长显示精度的方法
  • 调整VS Code内置设置
    打开VS Code设置面板(快捷键Ctrl+,或Cmd+,),搜索jupyter.executionTimerPrecision,将默认的1(保留1位小数)修改为更大的数值,比如3即可显示毫秒级时长(如0.045s),设置为6则能显示微秒级精度。修改后重启Jupyter内核就能生效。

  • 手动添加计时代码
    如果内置指示器的精度还是不够,可以在单元格里手动插入计时逻辑,直接输出精确时长:

    import time
    start = time.perf_counter()
    
    # 这里写你的业务代码
    pass
    
    elapsed = time.perf_counter() - start
    print(f"精确运行时长: {elapsed:.6f} 秒")
    

    这种方式不受VS Code界面限制,能直接获取到微秒级的计时结果。

内容的提问来源于stack exchange,提问作者userrandrand

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 14:43:12