test.java
来自「PracticalJAVACode 的源码」· Java 代码 · 共 28 行
JAVA
28 行
class Test
{
public static void main(String args[])
{
System.gc();
long start = System.currentTimeMillis();
for (int i=0; i<100000; i++)
{
Light lgt = new Light(1);
}
long end = System.currentTimeMillis();
long val = end-start;
System.out.println("Light is " + (end-start));
System.gc();
start = System.currentTimeMillis();
for (int i=0; i<1; i++)
{
Heavy hvy = new Heavy(4, true);
}
end = System.currentTimeMillis();
System.out.println("heavy is " + (end-start));
val = (end-start)/val;
System.out.println("heavy is " + val + " times more expensive");
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?