Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish gh-5688 #5755

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,29 @@ public class GaugeBenchmark {

private MeterRegistry registry;

private AtomicInteger stateObject;

@Setup
public void setup() {
registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
stateObject = registry.gauge("test.gauge", new AtomicInteger());
registry.gauge("test.gauge", new AtomicInteger());
// emits warn because of double registration
stateObject = registry.gauge("test.gauge", new AtomicInteger());
registry.gauge("test.gauge", new AtomicInteger());
// emits debug because of double registration and keeps emitting debug from now on
stateObject = registry.gauge("test.gauge", new AtomicInteger());
registry.gauge("test.gauge", new AtomicInteger());
}

@Benchmark
public AtomicInteger baseline() {
stateObject = new AtomicInteger();
return stateObject;
return new AtomicInteger();
}

@Benchmark
public AtomicInteger gaugeReRegistrationWithoutBuilder() {
stateObject = registry.gauge("test.gauge", new AtomicInteger());
return stateObject;
return registry.gauge("test.gauge", new AtomicInteger());
}

@Benchmark
public Gauge gaugeReRegistrationWithBuilder() {
stateObject = new AtomicInteger();
return Gauge.builder("test.gauge", stateObject, AtomicInteger::doubleValue).register(registry);
return Gauge.builder("test.gauge", new AtomicInteger(), AtomicInteger::doubleValue).register(registry);
}

public static void main(String[] args) throws RunnerException {
Expand Down
Loading