package dev.elaine.jvmlab;

public final class JitWarmupSample {
    private JitWarmupSample() {
    }

    public static long calculate(int iterations) {
        long result = 1;
        for (int index = 1; index <= iterations; index++) {
            result = (result * 31 + index) & 0x7fff_ffffL;
        }
        return result;
    }

    public static void main(String[] args) {
        int rounds = args.length == 0 ? 20_000 : Integer.parseInt(args[0]);
        long checksum = 0;
        for (int round = 0; round < rounds; round++) {
            checksum ^= calculate(1_000);
        }
        System.out.println("校验值=" + checksum);
    }
}
