Performance engineering

Seeded benchmark inputs

Exercise varied reproducible values. Executed Java 21 functional example, not a performance claim.

Formal Syntax & Structure

java syntaxjava
new Random(seed)

Working Example

Example Snippetjava
public class Main {    static long baseline(int[] a) { return sum(a.clone()); }    static long variant(int[] a) { return sum(a); }    static long sum(int[] a) { long n=0; for(int x:a) n+=x; return n; }    public static void main(String[] args) {        var random=new java.util.Random(51);        int[] a=new int[32];        for(int i=0;i<a.length;i++) a[i]=random.nextInt(101)-50;        int[] before=a.clone();        System.out.println(baseline(a)==variant(a));        System.out.println(java.util.Arrays.equals(a,before));    }}
Java Reference