blob: 1f04a5847f7eb60a94ee37ca41d5580b3cb8dd0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/* Copied from https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_14/SingleSource/Benchmarks
* License: LLVM Release License. See Notice file
*/
package org.linaro.benchmarks.stanford;
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Benchmark)
public class Perm {
private static final int permrange = 10;
private boolean error;
/* Perm */
private int[] permarray = new int [permrange + 1];
/* converted pctr to unsigned int for 16 bit WR*/
private int pctr;
// CHECKSTYLE.OFF: .*
/* Permutation program, heavily recursive, written by Denny Brown. */
void Swap ( int a[], int ai, int b[], int bi ) {
int t;
t = a[ai]; a[ai] = b[bi]; b[bi] = t;
}
void Initialize () {
int i;
for ( i = 1; i <= 7; i++ ) {
permarray[i]=i-1;
}
}
void Permute (int n) { /* permute */
int k;
pctr = pctr + 1;
if ( n!=1 ) {
Permute(n-1);
for ( k = n-1; k >= 1; k-- ) {
Swap(permarray, n, permarray, k);
Permute(n-1);
Swap(permarray, n, permarray, k);
}
}
} /* permute */
void Perm () { /* Perm */
int i;
pctr = 0;
for ( i = 1; i <= 5; i++ ) {
Initialize();
Permute(7);
}
if ( pctr != 43300 )
error = true;
} /* Perm */
// CHECKSTYLE.ON: .*
@Benchmark
public void jmhTimePerm() {
Perm();
}
}
|