Skip to content

Commit 40d8794

Browse files
committed
add super linter
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent ca955bc commit 40d8794

File tree

117 files changed

+122950
-7956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+122950
-7956
lines changed

.github/super-linter.env

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FILTER_REGEX_EXCLUDE=mvnw
2+
IGNORE_GITIGNORED_FILES=true
3+
JAVA_FILE_NAME=google_checks.xml
4+
# disable kubernetes linter - complains about resource limits, etc
5+
VALIDATE_CHECKOV=false
6+
VALIDATE_DOCKERFILE_HADOLINT=false
7+
VALIDATE_GIT_COMMITLINT=false
8+
# times out
9+
VALIDATE_GO_MODULES=false
10+
# contradicting with prettier
11+
VALIDATE_JAVASCRIPT_STANDARD=false
12+
# we have many duplicate code in our codebase for demo purposes
13+
VALIDATE_JSCPD=false
14+
15+
FIX_ENV=true
16+
FIX_GOOGLE_JAVA_FORMAT=true
17+
FIX_JAVASCRIPT_PRETTIER=true
18+
FIX_JSON=true
19+
FIX_JSONC=true
20+
FIX_JSONC_PRETTIER=true
21+
FIX_JSON_PRETTIER=true
22+
FIX_MARKDOWN=true
23+
FIX_MARKDOWN_PRETTIER=true
24+
FIX_SHELL_SHFMT=true
25+
FIX_YAML_PRETTIER=true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ jobs:
1616
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1717
- uses: jdx/mise-action@7a111ead46986ccad89a74ad013ba2a7c08c9e67 # v2.1.1
1818
- name: Lint
19-
run: mise run lint-all
19+
run: mise run lint-rest
2020

.github/workflows/super-linter.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Lint
3+
4+
on:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-24.04
10+
11+
permissions:
12+
contents: read
13+
packages: read
14+
# To report GitHub Actions status checks
15+
statuses: write
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
with:
21+
persist-credentials: false
22+
fetch-depth: 0
23+
24+
- name: Load super-linter configuration
25+
run: grep -v '^#' .github/super-linter.env | grep -v 'FIX_' >> "$GITHUB_ENV"
26+
27+
- name: Super-linter
28+
uses: super-linter/super-linter@4e8a7c2bf106c4c766c816b35ec612638dc9b6b2 # v7.3.0
29+
env:
30+
# To report GitHub Actions status checks
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ dependency-reduced-pom.xml
1818
**/.classpath
1919
**.project
2020
**/.settings/
21+
docs/public
22+
.lycheecache
Lines changed: 116 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,132 @@
11
package io.prometheus.client;
22

33
import io.prometheus.client.CKMSQuantiles.Quantile;
4+
import java.util.ArrayList;
5+
import java.util.Collections;
6+
import java.util.List;
7+
import java.util.Random;
8+
import java.util.concurrent.TimeUnit;
49
import org.openjdk.jmh.annotations.*;
510
import org.openjdk.jmh.infra.Blackhole;
611
import org.openjdk.jmh.runner.Runner;
712
import org.openjdk.jmh.runner.RunnerException;
813
import org.openjdk.jmh.runner.options.Options;
914
import org.openjdk.jmh.runner.options.OptionsBuilder;
1015

11-
import java.util.ArrayList;
12-
import java.util.Collections;
13-
import java.util.List;
14-
import java.util.Random;
15-
import java.util.concurrent.TimeUnit;
16-
1716
public class CKMSQuantileBenchmark {
1817

19-
@State(Scope.Benchmark)
20-
public static class EmptyBenchmarkState {
21-
@Param({"10000", "100000", "1000000"})
22-
public int value;
23-
24-
List<Quantile> quantiles;
25-
Random rand = new Random(0);
26-
27-
List<Double> shuffle;
28-
29-
Quantile mean = new Quantile(0.50, 0.050);
30-
Quantile q90 = new Quantile(0.90, 0.010);
31-
Quantile q95 = new Quantile(0.95, 0.005);
32-
Quantile q99 = new Quantile(0.99, 0.001);
33-
34-
@Setup(Level.Trial)
35-
public void setup() {
36-
quantiles = new ArrayList<Quantile>();
37-
quantiles.add(mean);
38-
quantiles.add(q90);
39-
quantiles.add(q95);
40-
quantiles.add(q99);
41-
42-
shuffle = new ArrayList<Double>(value);
43-
for (int i = 0; i < value; i++) {
44-
shuffle.add((double) i);
45-
}
46-
Collections.shuffle(shuffle, rand);
47-
}
48-
}
49-
50-
@Benchmark
51-
@BenchmarkMode({Mode.AverageTime})
52-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
53-
public void ckmsQuantileInsertBenchmark(EmptyBenchmarkState state) {
54-
CKMSQuantiles q = new CKMSQuantiles(state.quantiles.toArray(new Quantile[]{}));
55-
for (Double l : state.shuffle) {
56-
q.insert(l);
57-
}
58-
}
59-
60-
/** prefilled benchmark, means that we already have a filled and compressed samples available */
61-
@State(Scope.Benchmark)
62-
public static class PrefilledBenchmarkState {
63-
@Param({"10000", "100000", "1000000"})
64-
public int value;
65-
66-
67-
CKMSQuantiles ckmsQuantiles;
68-
69-
List<Quantile> quantiles;
70-
Random rand = new Random(0);
71-
72-
Quantile mean = new Quantile(0.50, 0.050);
73-
Quantile q90 = new Quantile(0.90, 0.010);
74-
Quantile q95 = new Quantile(0.95, 0.005);
75-
Quantile q99 = new Quantile(0.99, 0.001);
76-
List<Double> shuffle;
77-
78-
int rank = (int) (value * q95.quantile);
79-
80-
81-
@Setup(Level.Trial)
82-
public void setup() {
83-
quantiles = new ArrayList<Quantile>();
84-
quantiles.add(mean);
85-
quantiles.add(q90);
86-
quantiles.add(q95);
87-
quantiles.add(q99);
88-
89-
shuffle = new ArrayList<Double>(value);
90-
for (int i = 0; i < value; i++) {
91-
shuffle.add((double) i);
92-
}
93-
Collections.shuffle(shuffle, rand);
94-
95-
96-
ckmsQuantiles = new CKMSQuantiles(quantiles.toArray(new Quantile[]{}));
97-
for (Double l : shuffle) {
98-
ckmsQuantiles.insert(l);
99-
}
100-
// make sure we inserted all 'hanging' samples (count % 128)
101-
ckmsQuantiles.get(0);
102-
// compress everything so we have a similar samples size regardless of n.
103-
ckmsQuantiles.compress();
104-
System.out.println("Sample size is: " + ckmsQuantiles.samples.size());
105-
}
106-
107-
}
108-
109-
@Benchmark
110-
@BenchmarkMode({Mode.AverageTime})
111-
@OutputTimeUnit(TimeUnit.NANOSECONDS)
112-
public void ckmsQuantileGetBenchmark(Blackhole blackhole, PrefilledBenchmarkState state) {
113-
blackhole.consume(state.ckmsQuantiles.get(state.q90.quantile));
18+
@State(Scope.Benchmark)
19+
public static class EmptyBenchmarkState {
20+
@Param({"10000", "100000", "1000000"})
21+
public int value;
22+
23+
List<Quantile> quantiles;
24+
Random rand = new Random(0);
25+
26+
List<Double> shuffle;
27+
28+
Quantile mean = new Quantile(0.50, 0.050);
29+
Quantile q90 = new Quantile(0.90, 0.010);
30+
Quantile q95 = new Quantile(0.95, 0.005);
31+
Quantile q99 = new Quantile(0.99, 0.001);
32+
33+
@Setup(Level.Trial)
34+
public void setup() {
35+
quantiles = new ArrayList<Quantile>();
36+
quantiles.add(mean);
37+
quantiles.add(q90);
38+
quantiles.add(q95);
39+
quantiles.add(q99);
40+
41+
shuffle = new ArrayList<Double>(value);
42+
for (int i = 0; i < value; i++) {
43+
shuffle.add((double) i);
44+
}
45+
Collections.shuffle(shuffle, rand);
11446
}
115-
116-
/**
117-
* benchmark for the f method.
118-
*/
119-
@Benchmark
120-
@BenchmarkMode({Mode.AverageTime})
121-
@OutputTimeUnit(TimeUnit.NANOSECONDS)
122-
public void ckmsQuantileF(Blackhole blackhole, PrefilledBenchmarkState state) {
123-
blackhole.consume(state.ckmsQuantiles.f(state.rank));
47+
}
48+
49+
@Benchmark
50+
@BenchmarkMode({Mode.AverageTime})
51+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
52+
public void ckmsQuantileInsertBenchmark(EmptyBenchmarkState state) {
53+
CKMSQuantiles q = new CKMSQuantiles(state.quantiles.toArray(new Quantile[] {}));
54+
for (Double l : state.shuffle) {
55+
q.insert(l);
12456
}
125-
126-
public static void main(String[] args) throws RunnerException {
127-
128-
Options opt = new OptionsBuilder()
129-
.include(CKMSQuantileBenchmark.class.getSimpleName())
130-
.warmupIterations(5)
131-
.measurementIterations(4)
132-
.threads(1)
133-
.forks(1)
134-
.build();
135-
136-
new Runner(opt).run();
57+
}
58+
59+
/** prefilled benchmark, means that we already have a filled and compressed samples available */
60+
@State(Scope.Benchmark)
61+
public static class PrefilledBenchmarkState {
62+
@Param({"10000", "100000", "1000000"})
63+
public int value;
64+
65+
CKMSQuantiles ckmsQuantiles;
66+
67+
List<Quantile> quantiles;
68+
Random rand = new Random(0);
69+
70+
Quantile mean = new Quantile(0.50, 0.050);
71+
Quantile q90 = new Quantile(0.90, 0.010);
72+
Quantile q95 = new Quantile(0.95, 0.005);
73+
Quantile q99 = new Quantile(0.99, 0.001);
74+
List<Double> shuffle;
75+
76+
int rank = (int) (value * q95.quantile);
77+
78+
@Setup(Level.Trial)
79+
public void setup() {
80+
quantiles = new ArrayList<Quantile>();
81+
quantiles.add(mean);
82+
quantiles.add(q90);
83+
quantiles.add(q95);
84+
quantiles.add(q99);
85+
86+
shuffle = new ArrayList<Double>(value);
87+
for (int i = 0; i < value; i++) {
88+
shuffle.add((double) i);
89+
}
90+
Collections.shuffle(shuffle, rand);
91+
92+
ckmsQuantiles = new CKMSQuantiles(quantiles.toArray(new Quantile[] {}));
93+
for (Double l : shuffle) {
94+
ckmsQuantiles.insert(l);
95+
}
96+
// make sure we inserted all 'hanging' samples (count % 128)
97+
ckmsQuantiles.get(0);
98+
// compress everything so we have a similar samples size regardless of n.
99+
ckmsQuantiles.compress();
100+
System.out.println("Sample size is: " + ckmsQuantiles.samples.size());
137101
}
102+
}
103+
104+
@Benchmark
105+
@BenchmarkMode({Mode.AverageTime})
106+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
107+
public void ckmsQuantileGetBenchmark(Blackhole blackhole, PrefilledBenchmarkState state) {
108+
blackhole.consume(state.ckmsQuantiles.get(state.q90.quantile));
109+
}
110+
111+
/** benchmark for the f method. */
112+
@Benchmark
113+
@BenchmarkMode({Mode.AverageTime})
114+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
115+
public void ckmsQuantileF(Blackhole blackhole, PrefilledBenchmarkState state) {
116+
blackhole.consume(state.ckmsQuantiles.f(state.rank));
117+
}
118+
119+
public static void main(String[] args) throws RunnerException {
120+
121+
Options opt =
122+
new OptionsBuilder()
123+
.include(CKMSQuantileBenchmark.class.getSimpleName())
124+
.warmupIterations(5)
125+
.measurementIterations(4)
126+
.threads(1)
127+
.forks(1)
128+
.build();
129+
130+
new Runner(opt).run();
131+
}
138132
}

0 commit comments

Comments
 (0)