package com.github.vertical_blank.sqlformatter;

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*;
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;

@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
public class Benchmark {

  public static final String SQL =
      "SELECT foo, bar, CASE baz WHEN 'one' THEN 1 WHEN 'two' THEN 2 ELSE 3 END FROM table";

  public static void main(String[] args) throws RunnerException {
    Options opt = new OptionsBuilder().include(Benchmark.class.getSimpleName()).forks(1).build();

    new Runner(opt).run();
  }

  @org.openjdk.jmh.annotations.Benchmark
  public void format() {
    SqlFormatter.format(SQL);
  }
}
