This is an automated email from the ASF dual-hosted git repository. siddteotia pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new 50cdd28e9e Benchmark thread cpu time (#9408) 50cdd28e9e is described below commit 50cdd28e9e3ac16a910f63318edcaa8b38230b4c Author: Jia Guo <jia...@linkedin.com> AuthorDate: Thu Sep 15 18:33:06 2022 -0700 Benchmark thread cpu time (#9408) * Benchmark ThreadMXBean CPU Time * Benchmark ThreadMXBean CPU Time * Benchmark ThreadMXBean CPU Time --- .../perf/BenchmarkThreadMXBeanThreadCPUTime.java | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkThreadMXBeanThreadCPUTime.java b/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkThreadMXBeanThreadCPUTime.java new file mode 100644 index 0000000000..b889e4203b --- /dev/null +++ b/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkThreadMXBeanThreadCPUTime.java @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.perf; + +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadMXBean; +import java.util.concurrent.TimeUnit; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.TimeValue; + + +@State(Scope.Benchmark) +public class BenchmarkThreadMXBeanThreadCPUTime { + + public static void main(String[] args) + throws RunnerException { + Options opt = + new OptionsBuilder().include(BenchmarkThreadMXBeanThreadCPUTime.class.getSimpleName()) + .warmupTime(TimeValue.seconds(5)) + .warmupIterations(3).measurementTime(TimeValue.seconds(10)).measurementIterations(5).forks(1).build(); + + new Runner(opt).run(); + } + + @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.MILLISECONDS) + public void benchThreadMXBeanThreadCPUTime(MyState myState, Blackhole bh) { + for (int i = 0; i < 1000; i++) { + bh.consume(myState._threadMXBean.getCurrentThreadCpuTime()); + } + } + + @State(Scope.Benchmark) + public static class MyState { + public ThreadMXBean _threadMXBean; + + @Setup(Level.Iteration) + public void doSetup() { + _threadMXBean = ManagementFactory.getThreadMXBean(); + } + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org