System

 

 

方法

数组相关

arraycopy

Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.

从源数组中的指定位置开始 到 目标数组的指定位置开始,

 

public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length);

  src:      the source array.              源数组

  srcPos:   starting position in the source array.     源数组的起始位置

  dest:     the destination array.            目标数组

  destPos:  starting position in the destination data.   目标数组的起始位置

  length:   the number of array elements to be copied.    被拷贝的数组元素数量

  

时间相关

currentTimeMillis

Returns the current time in milliseconds.
Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger.

以ms为单位,返回当前时间;

从 1970 年 1 月 1 日 00:00:00 UTC(协调世界时)开始到现在经过的毫秒数;

精度是毫秒(1/1000秒)

 

public static native long currentTimeMillis();

 

使用场景

  处理日期、时间戳或者与实际世界时间相关的操作,应该使用 System.currentTimeMillis()

 

nanoTime

Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds.

以纳秒为单位,返回当前JVM

This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time.
The value returned represents nanoseconds since some fixed but arbitrary <i>origin</i> time (perhaps in the future, so values may be negative).

只能用于测量经过的时间;

返回的时间 表示 从某个固定的任意时间 到 现在经过的纳秒数;

精度是纳秒(1/1,000,000,000秒)

 

public static native long nanoTime();

 

使用场景

  精确地测量代码片段的执行时间,尤其是在进行性能分析或优化时,应使用 System.nanoTime()

    

posted on   anpeiyong  阅读(14)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示