Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/micro/org/openjdk/bench/java/util/TestAdler32.java
41161 views
1
/*
2
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
package org.openjdk.bench.java.util;
24
25
import java.util.Random;
26
import java.util.concurrent.TimeUnit;
27
import java.util.zip.Adler32;
28
import org.openjdk.jmh.annotations.*;
29
30
@BenchmarkMode(Mode.AverageTime)
31
@OutputTimeUnit(TimeUnit.MICROSECONDS)
32
@State(Scope.Benchmark)
33
@Fork(value = 2)
34
@Warmup(iterations = 2, time = 30, timeUnit = TimeUnit.SECONDS)
35
@Measurement(iterations = 3, time = 60, timeUnit = TimeUnit.SECONDS)
36
37
public class TestAdler32 {
38
39
private Adler32 adler32;
40
private Random random;
41
private byte[] bytes;
42
43
@Param({"64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384", "32768", "65536"})
44
private int count;
45
46
public TestAdler32() {
47
adler32 = new Adler32();
48
random = new Random(2147483648L);
49
bytes = new byte[1000000];
50
random.nextBytes(bytes);
51
}
52
53
@Setup(Level.Iteration)
54
public void setupBytes() {
55
adler32.reset();
56
}
57
58
@Benchmark
59
public void testAdler32Update() {
60
adler32.update(bytes, 0, count);
61
}
62
}
63
64