惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
aimingoo的专栏
aimingoo的专栏
腾讯CDC
T
The Blog of Author Tim Ferriss
D
Docker
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
Vercel News
Vercel News
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
量子位
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Proofpoint News Feed
博客园 - 叶小钗
宝玉的分享
宝玉的分享
雷峰网
雷峰网
Last Week in AI
Last Week in AI
B
Blog
A
About on SuperTechFans

博客园 - 昕

Egret飞行模拟-开发记录03-LoadingUI界面 Egret飞行模拟-开发记录02 Egret飞行模拟-开发记录01 python学习笔记之五 中岛美雪——疑似穿越人物 tensorflow学习001——MNIST 机器学习笔记之三-yolov3+win7+vs2017+gpu+opencv编译 机器学习笔记之二-win10+cuda9.1+CUDNN7+Anaconda3+VS2017+tensorflow1.5+opencv3.4 机器学习笔记之一 python网页爬虫开发之七-多线程爬虫示例01 python学习笔记之四-多进程&多线程&异步非阻塞 python网页爬虫开发之六-Selenium使用 python网页爬虫开发之五-反爬 python网页爬虫开发之四-串行爬虫代码示例 python网页爬虫开发之三 python网页爬虫开发之二 U3D学习14-一阶段学习总结 U3D学习13-数据存储 U3D学习12-黑暗之光实例
python学习笔记之三-计算运行时间
· 2018-10-25 · via 博客园 - 昕

方法1

import datetime

starttime = datetime.datetime.now()

#long running

endtime = datetime.datetime.now()

print (endtime - starttime).seconds

方法 2

start = time.time()

run_fun()

end = time.time()

print end-start

方法3

start = time.clock()

run_fun()

end = time.clock()

print end-start

方法1和方法2都包含了其他程序使用CPU的时间,是程序开始到程序结束的运行时间。

方法3算只计算了程序运行的CPU时间