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

推荐订阅源

WordPress大学
WordPress大学
V
Visual Studio Blog
P
Privacy International News Feed
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
T
Threatpost
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
小众软件
小众软件
L
LINUX DO - 最新话题
C
Cisco Blogs
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
罗磊的独立博客
V
V2EX
博客园 - Franky
P
Proofpoint News Feed
SecWiki News
SecWiki News
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

博客园 - 温少

新写了一个Java并发程序设计教程 佛教典故 绝世名将 Google云计算体验感受 我在Google AppEngine上部署了一个Java应用(OpenID测试) 杂谈单点登陆以及相关技术 喜闻我的文章进入“多核技术博客征文” top 30 重读罗素《西方哲学史》关于浪漫主义部分的介绍 随想 javaeye站点被ARP攻击有感 对如何建设一个可运维高可靠的SAAS平台,我终于有了想法!!! 获奖2008年金蝶集团优秀员工感言 也说一种普遍错误使用的LOG方式 2008年总结 关于技术架构师的一些看法 FileIterator 使用JSON替代XML 回想过去几年软件业的荒唐事 JPA这个烂东西
Java中的System.nano()很慢
温少 · 2010-12-02 · via 博客园 - 温少

System.nano()调用耗时450 nano,超级慢,比new Object()的操作慢100倍。

经一群无聊好事者查证,System.nanoTime()在linux下的实现,最终调用clock_gettime系统函数。

100万次调用耗时,java语言中System.nanoTime()和C语言中的clock_gettime()调用时间基本一致,所以System.nanoTime()慢的原因就是系统调用clock_gettime。

无聊好事者请注意,自行测试System.nanoTime()性能时,要这样写:

for (int i = 0; i < 1000 * 1000++i) {
    
long v = System.nanoTime();
}

而不能这样写:

for (int i = 0; i < 1000 * 1000++i) {
    System.nanoTime();
}