2025-07-15 21:16:06 -07:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
2025-11-08 16:22:34 -08:00
|
|
|
package wpilib.robot;
|
2025-07-15 21:16:06 -07:00
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import org.openjdk.jmh.annotations.Benchmark;
|
|
|
|
|
import org.openjdk.jmh.annotations.BenchmarkMode;
|
|
|
|
|
import org.openjdk.jmh.annotations.Mode;
|
|
|
|
|
import org.openjdk.jmh.annotations.OutputTimeUnit;
|
|
|
|
|
import org.openjdk.jmh.profile.GCProfiler;
|
|
|
|
|
import org.openjdk.jmh.runner.Runner;
|
|
|
|
|
import org.openjdk.jmh.runner.RunnerException;
|
|
|
|
|
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
|
|
|
|
import org.openjdk.jmh.runner.options.TimeValue;
|
2025-11-07 19:57:21 -05:00
|
|
|
import org.wpilib.math.geometry.Pose2d;
|
2025-07-15 21:16:06 -07:00
|
|
|
|
|
|
|
|
public class Main {
|
|
|
|
|
/**
|
|
|
|
|
* Main function.
|
|
|
|
|
*
|
|
|
|
|
* @param args The (unused) arguments to the program.
|
|
|
|
|
*/
|
|
|
|
|
public static void main(String... args) throws RunnerException {
|
2025-11-10 10:36:21 -08:00
|
|
|
var opt =
|
2025-07-15 21:16:06 -07:00
|
|
|
new OptionsBuilder()
|
|
|
|
|
.include(Main.class.getSimpleName())
|
|
|
|
|
.addProfiler(GCProfiler.class)
|
|
|
|
|
.forks(1)
|
|
|
|
|
.warmupIterations(2)
|
|
|
|
|
.warmupTime(TimeValue.seconds(3))
|
|
|
|
|
.measurementIterations(3)
|
|
|
|
|
.measurementTime(TimeValue.seconds(3))
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
new Runner(opt).run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Benchmark
|
|
|
|
|
@BenchmarkMode(Mode.AverageTime)
|
|
|
|
|
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
2025-11-10 10:36:21 -08:00
|
|
|
public Pose2d[] travelingSalesmanTransform() {
|
|
|
|
|
return TravelingSalesmanBenchmark.transform();
|
2025-07-15 21:16:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Benchmark
|
|
|
|
|
@BenchmarkMode(Mode.AverageTime)
|
|
|
|
|
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
2025-11-10 10:36:21 -08:00
|
|
|
public Pose2d[] travelingSalesmanTwist() {
|
|
|
|
|
return TravelingSalesmanBenchmark.twist();
|
2025-07-15 21:16:06 -07:00
|
|
|
}
|
|
|
|
|
}
|