我们看到粒度delta变为了1ms。循环次数frequency平均为676,也就是说每个循环运运行耗时1/676=0.001479ms=1479ns,与上一个测试结果的1467ns吻合。
结论:如果你的Java程序需要高精度的计时,如1毫秒或者更小,使用System.nanoTime()方法,它完全可以满足你的需求。如果不行的话,建议你换台更快的机器试试:)
我的测试:win7 64位机器
raw=1493570859935 | formatted=01-五月-2017 00:47:39:935 | frequency=6704 | delta=0ms
raw=1493570859936 | formatted=01-五月-2017 00:47:39:936 | frequency=3206 | delta=1ms
raw=1493570859937 | formatted=01-五月-2017 00:47:39:937 | frequency=7577 | delta=1ms
raw=1493570859938 | formatted=01-五月-2017 00:47:39:938 | frequency=11850 | delta=1ms
raw=1493570859939 | formatted=01-五月-2017 00:47:39:939 | frequency=11980 | delta=1ms
raw=1493570859940 | formatted=01-五月-2017 00:47:39:940 | frequency=12024 | delta=1ms
raw=1493570859941 | formatted=01-五月-2017 00:47:39:941 | frequency=14463 | delta=1ms
raw=1493570859942 | formatted=01-五月-2017 00:47:39:942 | frequency=43736 | delta=1ms
raw=1493570859943 | formatted=01-五月-2017 00:47:39:943 | frequency=29821 | delta=1ms
raw=1493570859944 | formatted=01-五月-2017 00:47:39:944 | frequency=37073 | delta=1ms
raw=1493570859945 | formatted=01-五月-2017 00:47:39:945 | frequency=39123 | delta=1ms
raw=1493570859946 | formatted=01-五月-2017 00:47:39:946 | frequency=40013 | delta=1ms
raw=1493570859947 | formatted=01-五月-2017 00:47:39:947 | frequency=39849 | delta=1ms
raw=1493570859948 | formatted=01-五月-2017 00:47:39:948 | frequency=39360 | delta=1ms
raw=1493570859949 | formatted=01-五月-2017 00:47:39:949 | frequency=39363 | delta=1ms
raw=1493570859950 | formatted=01-五月-2017 00:47:39:950 | frequency=39382 | delta=1ms
raw=1493570859951 | formatted=01-五月-2017 00:47:39:951 | frequency=38224 | delta=1ms
raw=1493570859952 | formatted=01-五月-2017 00:47:39:952 | frequency=39971 | delta=1ms
raw=1493570859953 | formatted=01-五月-2017 00:47:39:953 | frequency=39263 | delta=1ms
raw=1493570859954 | formatted=01-五月-2017 00:47:39:954 | frequency=34094 | delta=1ms
raw=1493570859955 | formatted=01-五月-2017 00:47:39:955 | frequency=39970 | delta=1ms
raw=1493570859956 | formatted=01-五月-2017 00:47:39:956 | frequency=39189 | delta=1ms
raw=1493570859957 | formatted=01-五月-2017 00:47:39:957 | frequency=38741 | delta=1ms
raw=1493570859958 | formatted=01-五月-2017 00:47:39:958 | frequency=38910 | delta=1ms
raw=1493570859959 | formatted=01-五月-2017 00:47:39:959 | frequency=38088 | delta=1ms
raw=1493570859960 | formatted=01-五月-2017 00:47:39:960 | frequency=39590 | delta=1ms
raw=1493570859961 | formatted=01-五月-2017 00:47:39:961 | frequency=38838 | delta=1ms
raw=1493570859962 | formatted=01-五月-2017 00:47:39:962 | frequency=38412 | delta=1ms
raw=1493570859963 | formatted=01-五月-2017 00:47:39:963 | frequency=37997 | delta=1ms
raw=1493570859964 | formatted=01-五月-2017 00:47:39:964 | frequency=38640 | delta=1ms
raw=1493570859965 | formatted=01-五月-2017 00:47:39:965 | frequency=38506 | delta=1ms
raw=1493570859966 | formatted=01-五月-2017 00:47:39:966 | frequency=36666 | delta=1ms
raw=1493570859967 | formatted=01-五月-2017 00:47:39:967 | frequency=31389 | delta=1ms
raw=1493570859968 | formatted=01-五月-2017 00:47:39:968 | frequency=38891 | delta=1ms
raw=1493570859969 | formatted=01-五月-2017 00:47:39:969 | frequency=38846 | delta=1ms
raw=1493570859970 | formatted=01-五月-2017 00:47:39:970 | frequency=38796 | delta=1ms
raw=1493570859971 | formatted=01-五月-2017 00:47:39:971 | frequency=36436 | delta=1ms
raw=1493570859972 | formatted=01-五月-2017 00:47:39:972 | frequency=38752 | delta=1ms
raw=1493570859973 | formatted=01-五月-2017 00:47:39:973 | frequency=38485 | delta=1ms
raw=1493570859974 | formatted=01-五月-2017 00:47:39:974 | frequency=38882 | delta=1ms
raw=1493570859975 | formatted=01-五月-2017 00:47:39:975 | frequency=38044 | delta=1ms
raw=1493570859976 | formatted=01-五月-2017 00:47:39:976 | frequency=34717 | delta=1ms
raw=1493570859977 | formatted=01-五月-2017 00:47:39:977 | frequency=38469 | delta=1ms
raw=1493570859978 | formatted=01-五月-2017 00:47:39:978 | frequency=38838 | delta=1ms
raw=1493570859979 | formatted=01-五月-2017 00:47:39:979 | frequency=38564 | delta=1ms
raw=1493570859980 | formatted=01-五月-2017 00:47:39:980 | frequency=38797 | delta=1ms
raw=1493570859981 | formatted=01-五月-2017 00:47:39:981 | frequency=36988 | delta=1ms
raw=1493570859982 | formatted=01-五月-2017 00:47:39:982 | frequency=38927 | delta=1ms
raw=1493570859983 | formatted=01-五月-2017 00:47:39:983 | frequency=34862 | delta=1ms
raw=1493570859984 | formatted=01-五月-2017 00:47:39:984 | frequency=38488 | delta=1ms
raw=1493570859985 | formatted=01-五月-2017 00:47:39:985 | frequency=38377 | delta=1ms
raw=1493570859986 | formatted=01-五月-2017 00:47:39:986 | frequency=36431 | delta=1ms
raw=1493570859987 | formatted=01-五月-2017 00:47:39:987 | frequency=39099 | delta=1ms
raw=1493570859988 | formatted=01-五月-2017 00:47:39:988 | frequency=39024 | delta=1ms
raw=1493570859989 | formatted=01-五月-2017 00:47:39:989 | frequency=38210 | delta=1ms
raw=1493570859990 | formatted=01-五月-2017 00:47:39:990 | frequency=38559 | delta=1ms
raw=1493570859991 | formatted=01-五月-2017 00:47:39:991 | frequency=36832 | delta=1ms
raw=1493570859992 | formatted=01-五月-2017 00:47:39:992 | frequency=38972 | delta=1ms
raw=1493570859993 | formatted=01-五月-2017 00:47:39:993 | frequency=38523 | delta=1ms
raw=1493570859994 | formatted=01-五月-2017 00:47:39:994 | frequency=38637 | delta=1ms
raw=1493570859995 | formatted=01-五月-2017 00:47:39:995 | frequency=39451 | delta=1ms
raw=1493570859996 | formatted=01-五月-2017 00:47:39:996 | frequency=39320 | delta=1ms
raw=1493570859997 | formatted=01-五月-2017 00:47:39:997 | frequency=39650 | delta=1ms
raw=1493570859998 | formatted=01-五月-2017 00:47:39:998 | frequency=39321 | delta=1ms
raw=1493570859999 | formatted=01-五月-2017 00:47:39:999 | frequency=31707 | delta=1ms
raw=1493570860000 | formatted=01-五月-2017 00:47:40:000 | frequency=39309 | delta=1ms
raw=1493570860001 | formatted=01-五月-2017 00:47:40:001 | frequency=38003 | delta=1ms
raw=1493570860002 | formatted=01-五月-2017 00:47:40:002 | frequency=39070 | delta=1ms
raw=1493570860003 | formatted=01-五月-2017 00:47:40:003 | frequency=37749 | delta=1ms
raw=1493570860004 | formatted=01-五月-2017 00:47:40:004 | frequency=28463 | delta=1ms
raw=1493570860005 | formatted=01-五月-2017 00:47:40:005 | frequency=38888 | delta=1ms
raw=1493570860006 | formatted=01-五月-2017 00:47:40:006 | frequency=38575 | delta=1ms
raw=1493570860007 | formatted=01-五月-2017 00:47:40:007 | frequency=39228 | delta=1ms
raw=1493570860008 | formatted=01-五月-2017 00:47:40:008 | frequency=38988 | delta=1ms
raw=1493570860009 | formatted=01-五月-2017 00:47:40:009 | frequency=37778 | delta=1ms
raw=1493570860010 | formatted=01-五月-2017 00:47:40:010 | frequency=37712 | delta=1ms
raw=1493570860011 | formatted=01-五月-2017 00:47:40:011 | frequency=28653 | delta=1ms
raw=1493570860012 | formatted=01-五月-2017 00:47:40:012 | frequency=38848 | delta=1ms
raw=1493570860013 | formatted=01-五月-2017 00:47:40:013 | frequency=43780 | delta=1ms
raw=1493570860014 | formatted=01-五月-2017 00:47:40:014 | frequency=40557 | delta=1ms
raw=1493570860015 | formatted=01-五月-2017 00:47:40:015 | frequency=39523 | delta=1ms
raw=1493570860016 | formatted=01-五月-2017 00:47:40:016 | frequency=39129 | delta=1ms
raw=1493570860017 | formatted=01-五月-2017 00:47:40:017 | frequency=39163 | delta=1ms
raw=1493570860018 | formatted=01-五月-2017 00:47:40:018 | frequency=43068 | delta=1ms
raw=1493570860019 | formatted=01-五月-2017 00:47:40:019 | frequency=43324 | delta=1ms
raw=1493570860020 | formatted=01-五月-2017 00:47:40:020 | frequency=42737 | delta=1ms
raw=1493570860021 | formatted=01-五月-2017 00:47:40:021 | frequency=37480 | delta=1ms
raw=1493570860022 | formatted=01-五月-2017 00:47:40:022 | frequency=38259 | delta=1ms
raw=1493570860023 | formatted=01-五月-2017 00:47:40:023 | frequency=39032 | delta=1ms
raw=1493570860024 | formatted=01-五月-2017 00:47:40:024 | frequency=39806 | delta=1ms
raw=1493570860025 | formatted=01-五月-2017 00:47:40:025 | frequency=40160 | delta=1ms
raw=1493570860026 | formatted=01-五月-2017 00:47:40:026 | frequency=40122 | delta=1ms
raw=1493570860027 | formatted=01-五月-2017 00:47:40:027 | frequency=38160 | delta=1ms
raw=1493570860028 | formatted=01-五月-2017 00:47:40:028 | frequency=39030 | delta=1ms
raw=1493570860029 | formatted=01-五月-2017 00:47:40:029 | frequency=39774 | delta=1ms
raw=1493570860030 | formatted=01-五月-2017 00:47:40:030 | frequency=33213 | delta=1ms
raw=1493570860031 | formatted=01-五月-2017 00:47:40:031 | frequency=37904 | delta=1ms
raw=1493570860032 | formatted=01-五月-2017 00:47:40:032 | frequency=38202 | delta=1ms
raw=1493570860033 | formatted=01-五月-2017 00:47:40:033 | frequency=37542 | delta=1ms
raw=1493570860034 | formatted=01-五月-2017 00:47:40:034 | frequency=39181 | delta=1ms
raw=1493570860035 | formatted=01-五月-2017 00:47:40:035 | frequency=38135 | delta=1ms
raw=1493570860036 | formatted=01-五月-2017 00:47:40:036 | frequency=39138 | delta=1ms
raw=1493570860037 | formatted=01-五月-2017 00:47:40:037 | frequency=39081 | delta=1ms
raw=1493570860038 | formatted=01-五月-2017 00:47:40:038 | frequency=39042 | delta=1ms
raw=1493570860039 | formatted=01-五月-2017 00:47:40:039 | frequency=39273 | delta=1ms
raw=1493570860040 | formatted=01-五月-2017 00:47:40:040 | frequency=38549 | delta=1ms
raw=1493570860041 | formatted=01-五月-2017 00:47:40:041 | frequency=31458 | delta=1ms
raw=1493570860042 | formatted=01-五月-2017 00:47:40:042 | frequency=39040 | delta=1ms
raw=1493570860043 | formatted=01-五月-2017 00:47:40:043 | frequency=38514 | delta=1ms
Minimum delta : 1ms
Maximum delta : 1ms