python统计秒数

code

1.没有cuda的版本

复制代码
import time

s = time.time()
for i in range(100):
	pass
t = time.time()
print("time:{} sec".format(t-s))

2.cuda 同步

复制代码
torch.cuda.synchronize()
start = time.time()
result = model(input)
torch.cuda.synchronize()
end = time.time()

ref

https://blog.csdn.net/qq_36268040/article/details/100085263

相关推荐
IT知识分享32 分钟前
从零开发在线简繁转换工具:OpenCC 实战、避坑经验与方案选型
javascript·python
lunzi_082637 分钟前
【学习笔记】《Python编程 从入门到实践》第8章:函数定义、参数传递与模块导入
笔记·python·学习
杨运交1 小时前
[030][Web模块]Spring Boot 验证与 OpenAPI 集成实战:从校验规则到文档生成
前端·spring boot·python
培培说证1 小时前
2026财务岗位如何快速提升自身能力
python
努力攻坚操作系统1 小时前
编程语言编译运行机制对比:C / Java / Python
java·c语言·python
godspeed_lucip1 小时前
LLM和Agent——专题6:Multi Agent 入门(5)
人工智能·python
Metaphor6922 小时前
使用 Python 给 PDF 设置背景色或背景图
数据库·python·pdf
郝亚军3 小时前
如何让pycharm-2026.1.2顶部菜单栏固定显示在最上端
python
怪兽学LLM3 小时前
LeetCode 438 找到字符串中所有字母异位词(Python 固定滑动窗口+字符计数解法)
python·算法·leetcode