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

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - 温少

新写了一个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();
}