Java 大θ:θ(n^3)算法的混淆时间输出

Java 大θ:θ(n^3)算法的混淆时间输出,java,big-o,Java,Big O,我正在对我变戏法的这个随机算法进行时间分析。结果让我困惑 public static void main(String[] args) { for (int size = 1000; size <= 10000000; size *= 4){ long start = System.nanoTime(); algorithm(size); long end = System.nanoTime();

我正在对我变戏法的这个随机算法进行时间分析。结果让我困惑

public static void main(String[] args) {
        for (int size = 1000; size <= 10000000; size *= 4){
            long start = System.nanoTime();
            algorithm(size);
            long end = System.nanoTime();
            System.out.println(size + " - " + (end-start)/1E6 + " ms");
        }
    }

    static void algorithm(int size){
        int count = 123456789;
        for (int a = 0; a < size; a++){
            for (int b = 0; b < size; b++){
                for (int c = 0; c < size; c++){
                    double blah = 0;
                    for (int k = 0; k < 1000; k++)
                        blah = Math.sqrt(count);
                }
            }
        }
    }

1000 - 711.623125 ms
4000 - 45053.60374 ms
16000 - 0.002234 ms
64000 - 0.001677 ms
256000 - 0.001676 ms
1024000 - 0.002794 ms
4096000 - 0.001676 ms
BUILD SUCCESSFUL (total time: 45 seconds)
publicstaticvoidmain(字符串[]args){

对于(int size=1000;size)您的方法
算法
不会产生任何影响。因此运行时决定删除它