8290391: Reduce runtime of java.util package microbenchmarks

Reviewed-by: rriggs, redestad
This commit is contained in:
Eric Caspole 2022-07-19 16:30:44 +00:00
parent bbc57483ce
commit 2cb659e7f4
16 changed files with 90 additions and 104 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,10 +24,13 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -38,6 +41,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class ArraysEquals { public class ArraysEquals {
public char[] testCharArray1 = "1234567890123456789012345678901234567890123456789012345678901234567890123456789a".toCharArray(); public char[] testCharArray1 = "1234567890123456789012345678901234567890123456789012345678901234567890123456789a".toCharArray();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
@ -39,9 +40,12 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.Throughput) @BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS) @OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class ArraysFill { public class ArraysFill {
@Param({"10", "16", "31", "59", "89", "126", "250", "266", "511", "1021", "2047", "2048", "4095", "8195"}) @Param({"16", "31", "250", "266", "511", "2047", "2048", "8195"})
public int size; public int size;
public byte[] testByteArray; public byte[] testByteArray;
@ -65,50 +69,36 @@ public class ArraysFill {
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public void testCharFill() { public void testCharFill() {
Arrays.fill(testCharArray, (char) -1); Arrays.fill(testCharArray, (char) -1);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public void testByteFill() { public void testByteFill() {
Arrays.fill(testByteArray, (byte) -1); Arrays.fill(testByteArray, (byte) -1);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public void testShortFill() { public void testShortFill() {
Arrays.fill(testShortArray, (short) -1); Arrays.fill(testShortArray, (short) -1);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public void testIntFill() { public void testIntFill() {
Arrays.fill(testIntArray, -1); Arrays.fill(testIntArray, -1);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public void testLongFill() { public void testLongFill() {
Arrays.fill(testLongArray, -1); Arrays.fill(testLongArray, -1);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public void testFloatFill() { public void testFloatFill() {
Arrays.fill(testFloatArray, (float) -1.0); Arrays.fill(testFloatArray, (float) -1.0);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public void testDoubleFill() { public void testDoubleFill() {
Arrays.fill(testDoubleArray, -1.0); Arrays.fill(testDoubleArray, -1.0);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,6 +33,7 @@ import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException; import javax.crypto.NoSuchPaddingException;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
@ -45,6 +46,9 @@ import org.openjdk.jmh.annotations.Warmup;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public abstract class ArraysMismatch { public abstract class ArraysMismatch {
@Param({"90", "800"}) @Param({"90", "800"})
@ -90,36 +94,26 @@ public abstract class ArraysMismatch {
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int matches() { public int matches() {
return Arrays.mismatch(left, right_matches); return Arrays.mismatch(left, right_matches);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int differentSubrangeMatches() { public int differentSubrangeMatches() {
return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange); return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchEnd() { public int mismatchEnd() {
return Arrays.mismatch(left, right_endMismatch); return Arrays.mismatch(left, right_endMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchMid() { public int mismatchMid() {
return Arrays.mismatch(left, right_midMismatch); return Arrays.mismatch(left, right_midMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchStart() { public int mismatchStart() {
return Arrays.mismatch(left, right_startMismatch); return Arrays.mismatch(left, right_startMismatch);
} }
@ -146,36 +140,26 @@ public abstract class ArraysMismatch {
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int matches() { public int matches() {
return Arrays.mismatch(left, right_matches); return Arrays.mismatch(left, right_matches);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int differentSubrangeMatches() { public int differentSubrangeMatches() {
return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange); return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchEnd() { public int mismatchEnd() {
return Arrays.mismatch(left, right_endMismatch); return Arrays.mismatch(left, right_endMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchMid() { public int mismatchMid() {
return Arrays.mismatch(left, right_midMismatch); return Arrays.mismatch(left, right_midMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchStart() { public int mismatchStart() {
return Arrays.mismatch(left, right_startMismatch); return Arrays.mismatch(left, right_startMismatch);
} }
@ -202,36 +186,26 @@ public abstract class ArraysMismatch {
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int matches() { public int matches() {
return Arrays.mismatch(left, right_matches); return Arrays.mismatch(left, right_matches);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int differentSubrangeMatches() { public int differentSubrangeMatches() {
return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange); return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchEnd() { public int mismatchEnd() {
return Arrays.mismatch(left, right_endMismatch); return Arrays.mismatch(left, right_endMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchMid() { public int mismatchMid() {
return Arrays.mismatch(left, right_midMismatch); return Arrays.mismatch(left, right_midMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchStart() { public int mismatchStart() {
return Arrays.mismatch(left, right_startMismatch); return Arrays.mismatch(left, right_startMismatch);
} }
@ -258,36 +232,26 @@ public abstract class ArraysMismatch {
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int matches() { public int matches() {
return Arrays.mismatch(left, right_matches); return Arrays.mismatch(left, right_matches);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int differentSubrangeMatches() { public int differentSubrangeMatches() {
return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange); return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchEnd() { public int mismatchEnd() {
return Arrays.mismatch(left, right_endMismatch); return Arrays.mismatch(left, right_endMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchMid() { public int mismatchMid() {
return Arrays.mismatch(left, right_midMismatch); return Arrays.mismatch(left, right_midMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchStart() { public int mismatchStart() {
return Arrays.mismatch(left, right_startMismatch); return Arrays.mismatch(left, right_startMismatch);
} }
@ -314,36 +278,26 @@ public abstract class ArraysMismatch {
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int matches() { public int matches() {
return Arrays.mismatch(left, right_matches); return Arrays.mismatch(left, right_matches);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int differentSubrangeMatches() { public int differentSubrangeMatches() {
return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange); return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchEnd() { public int mismatchEnd() {
return Arrays.mismatch(left, right_endMismatch); return Arrays.mismatch(left, right_endMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchMid() { public int mismatchMid() {
return Arrays.mismatch(left, right_midMismatch); return Arrays.mismatch(left, right_midMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchStart() { public int mismatchStart() {
return Arrays.mismatch(left, right_startMismatch); return Arrays.mismatch(left, right_startMismatch);
} }
@ -370,36 +324,26 @@ public abstract class ArraysMismatch {
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int matches() { public int matches() {
return Arrays.mismatch(left, right_matches); return Arrays.mismatch(left, right_matches);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int differentSubrangeMatches() { public int differentSubrangeMatches() {
return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange); return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchEnd() { public int mismatchEnd() {
return Arrays.mismatch(left, right_endMismatch); return Arrays.mismatch(left, right_endMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchMid() { public int mismatchMid() {
return Arrays.mismatch(left, right_midMismatch); return Arrays.mismatch(left, right_midMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchStart() { public int mismatchStart() {
return Arrays.mismatch(left, right_startMismatch); return Arrays.mismatch(left, right_startMismatch);
} }
@ -426,36 +370,26 @@ public abstract class ArraysMismatch {
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int matches() { public int matches() {
return Arrays.mismatch(left, right_matches); return Arrays.mismatch(left, right_matches);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int differentSubrangeMatches() { public int differentSubrangeMatches() {
return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange); return Arrays.mismatch(left, leftStartRange, leftEndRange, right_matches, rightStartRange, rightEndRange);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchEnd() { public int mismatchEnd() {
return Arrays.mismatch(left, right_endMismatch); return Arrays.mismatch(left, right_endMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchMid() { public int mismatchMid() {
return Arrays.mismatch(left, right_midMismatch); return Arrays.mismatch(left, right_midMismatch);
} }
@Benchmark @Benchmark
@Warmup(iterations = 3)
@Measurement(iterations = 3)
public int mismatchStart() { public int mismatchStart() {
return Arrays.mismatch(left, right_startMismatch); return Arrays.mismatch(left, right_startMismatch);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2022, cle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@ import java.util.Arrays;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
@ -38,9 +39,12 @@ import org.openjdk.jmh.annotations.Warmup;
@BenchmarkMode(Mode.Throughput) @BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS) @OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class ArraysMismatchPartialInlining { public class ArraysMismatchPartialInlining {
@Param({"3", "4", "5", "6", "7", "15", "31", "63", "95", "800"}) @Param({"3", "7", "15", "31", "63", "95", "800"})
private static int size; private static int size;
byte [] barray1; byte [] barray1;

View file

@ -34,6 +34,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class Base64Decode { public class Base64Decode {
private Base64.Encoder encoder, mimeEncoder; private Base64.Encoder encoder, mimeEncoder;

View file

@ -34,6 +34,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class Base64Encode { public class Base64Encode {
private Base64.Encoder encoder; private Base64.Encoder encoder;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle America, Inc. * Copyright (c) 2020, 2022, Oracle America, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,6 +34,9 @@ package org.openjdk.micro.bench.java.util;
import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.annotations.*;
import java.util.*; import java.util.*;
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class Base64VarLenDecode { public class Base64VarLenDecode {
@State(Scope.Thread) @State(Scope.Thread)
@ -44,7 +47,6 @@ public class Base64VarLenDecode {
ran = new Random(10101); // fixed seed for repeatability ran = new Random(10101); // fixed seed for repeatability
encoder = Base64.getEncoder(); encoder = Base64.getEncoder();
decoder = Base64.getDecoder(); decoder = Base64.getDecoder();
System.out.println("Do Trial Setup");
} }
@Setup(Level.Invocation) @Setup(Level.Invocation)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,10 +24,13 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.util.Date; import java.util.Date;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -35,6 +38,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class Dates { public class Dates {
int year = 75; int year = 75;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,11 +24,14 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
@ -37,6 +40,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class GregorianCalendars { public class GregorianCalendars {
private Calendar calendar; private Calendar calendar;

View file

@ -25,12 +25,15 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -45,6 +48,9 @@ import static java.util.stream.Collectors.toMap;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS) @OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class HashMapBench { public class HashMapBench {
private Supplier<Map<Integer, Integer>> mapSupplier; private Supplier<Map<Integer, Integer>> mapSupplier;
private Map<Integer, Integer> bigMapToAdd; private Map<Integer, Integer> bigMapToAdd;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,10 +24,13 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -38,6 +41,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark) @State(Scope.Benchmark)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class LocaleDefaults { public class LocaleDefaults {
@Benchmark @Benchmark

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,12 +24,16 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Warmup;
import java.util.random.RandomGenerator; import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory; import java.util.random.RandomGeneratorFactory;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -40,6 +44,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class RandomGeneratorNext { public class RandomGeneratorNext {
RandomGenerator randomGenerator; RandomGenerator randomGenerator;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,11 +24,14 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.util.Random; import java.util.Random;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -39,6 +42,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class RandomNext { public class RandomNext {
public Random rnd; public Random rnd;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,7 @@ public class TestAdler32 {
private Random random; private Random random;
private byte[] bytes; private byte[] bytes;
@Param({"64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384", "32768", "65536"}) @Param({"64", "128", "256", "512", /* "1024", */ "2048", /* "4096", "8192", */ "16384", /* "32768", */ "65536"})
private int count; private int count;
public TestAdler32() { public TestAdler32() {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,15 +30,16 @@ import org.openjdk.jmh.annotations.*;
@BenchmarkMode(Mode.Throughput) @BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS) @OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark) @State(Scope.Benchmark)
@Fork(value = 2) @Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class TestCRC32C { public class TestCRC32C {
private CRC32C crc32c; private CRC32C crc32c;
private Random random; private Random random;
private byte[] bytes; private byte[] bytes;
@Param({"64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384", "32768", "65536"}) @Param({"64", "128", "256", "512", /* "1024", */ "2048", /* "4096", "8192", */ "16384", /* "32768", */ "65536"})
private int count; private int count;
public TestCRC32C() { public TestCRC32C() {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,12 +24,15 @@ package org.openjdk.bench.java.util;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.infra.Blackhole;
import java.io.IOException; import java.io.IOException;
@ -44,6 +47,9 @@ import java.util.zip.ZipFile;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread) @State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
public class ZipFind { public class ZipFind {
// Files that exist in the microbenchmarks.jar zip file // Files that exist in the microbenchmarks.jar zip file