// Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
//   /**
//    * This field is here as a hack. This class is a shared dependency of both {@link
//    * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
//    * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
//    * being off in the trace event viewer, since the "start" time is since it was enabled, rather
//    * than when the first PerfMark call happens.
//    */
//   static final long INIT_NANO_TIME = System.nanoTime();
// 
//   /**
//    * The number of reserved bits at the bottom of the generation. All generations should be
//    * left-shifted by this amount.
//    */
//   public static final int GEN_OFFSET = 8;
//   /**
//    * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
//    * previous failure to set the generation. It can also be used to indicate the generation count
//    * has overflowed.
//    */
//   public static final long FAILURE = -2L << GEN_OFFSET;
// 
//   protected Generator() {}
// 
//   /**
//    * Sets the current generation count. This should be eventually noticeable for callers of {@link
//    * #getGeneration()}. An odd number means the library is enabled, while an even number means the
//    * library is disabled.
//    *
//    * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
//    */
//   public abstract void setGeneration(long generation);
// 
//   /**
//    * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
//    * library is enabled, while an even number means the library is disabled.
//    *
//    * @return the current generation or {@link #FAILURE}.
//    */
//   public abstract long getGeneration();
// 
//   /**
//    * Returns the approximate cost to change the generation.
//    *
//    * @return an approximate number of nanoseconds needed to change the generator value.
//    */
//   public long costOfSetNanos() {
//     return 1000000;
//   }
// 
//   /**
//    * Returns the approximate cost to read the generation.
//    *
//    * @return an approximate number of nanoseconds needed to read the generator value.
//    */
//   public long costOfGetNanos() {
//     return 10;
//   }
// }
// 
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
// 
//   public static final int NO_MAX_MARKS = -1;
// 
//   public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
// 
//   public abstract void start(long gen, String taskName, long nanoTime);
// 
//   public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
// 
//   public abstract void link(long gen, long linkId);
// 
//   public abstract void stop(long gen, long nanoTime);
// 
//   public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
// 
//   public abstract void stop(long gen, String taskName, long nanoTime);
// 
//   public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
// 
//   public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
// 
//   public abstract void event(long gen, String eventName, long nanoTime);
// 
//   public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
// 
//   public abstract void attachTag(long gen, String tagName, long tagId);
// 
//   public abstract void attachKeyedTag(long gen, String name, String value);
// 
//   public abstract void attachKeyedTag(long gen, String name, long value0);
// 
//   public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
// 
//   public abstract void resetForTest();
// 
//   public abstract List<Mark> read(boolean concurrentWrites);
// 
//   public int maxMarks() {
//     return NO_MAX_MARKS;
//   }
// 
//   protected MarkHolder() {}
// }


import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import java.util.List;
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.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
/*
 * Copyright 2019 Google LLC
 *
 * Licensed 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 io.perfmark.testing;


@State(Scope.Thread)
public class MarkHolderBenchmark {

  private static final long gen = 1 << Generator.GEN_OFFSET;
  private static final String taskName = "hiya";

// Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
//   /**
//    * This field is here as a hack. This class is a shared dependency of both {@link
//    * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
//    * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
//    * being off in the trace event viewer, since the "start" time is since it was enabled, rather
//    * than when the first PerfMark call happens.
//    */
//   static final long INIT_NANO_TIME = System.nanoTime();
// 
//   /**
//    * The number of reserved bits at the bottom of the generation. All generations should be
//    * left-shifted by this amount.
//    */
//   public static final int GEN_OFFSET = 8;
//   /**
//    * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
//    * previous failure to set the generation. It can also be used to indicate the generation count
//    * has overflowed.
//    */
//   public static final long FAILURE = -2L << GEN_OFFSET;
// 
//   protected Generator() {}
// 
//   /**
//    * Sets the current generation count. This should be eventually noticeable for callers of {@link
//    * #getGeneration()}. An odd number means the library is enabled, while an even number means the
//    * library is disabled.
//    *
//    * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
//    */
//   public abstract void setGeneration(long generation);
// 
//   /**
//    * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
//    * library is enabled, while an even number means the library is disabled.
//    *
//    * @return the current generation or {@link #FAILURE}.
//    */
//   public abstract long getGeneration();
// 
//   /**
//    * Returns the approximate cost to change the generation.
//    *
//    * @return an approximate number of nanoseconds needed to change the generator value.
//    */
//   public long costOfSetNanos() {
//     return 1000000;
//   }
// 
//   /**
//    * Returns the approximate cost to read the generation.
//    *
//    * @return an approximate number of nanoseconds needed to read the generator value.
//    */
//   public long costOfGetNanos() {
//     return 10;
//   }
// }
// 
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
// 
//   public static final int NO_MAX_MARKS = -1;
// 
//   public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
// 
//   public abstract void start(long gen, String taskName, long nanoTime);
// 
//   public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
// 
//   public abstract void link(long gen, long linkId);
// 
//   public abstract void stop(long gen, long nanoTime);
// 
//   public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
// 
//   public abstract void stop(long gen, String taskName, long nanoTime);
// 
//   public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
// 
//   public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
// 
//   public abstract void event(long gen, String eventName, long nanoTime);
// 
//   public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
// 
//   public abstract void attachTag(long gen, String tagName, long tagId);
// 
//   public abstract void attachKeyedTag(long gen, String name, String value);
// 
//   public abstract void attachKeyedTag(long gen, String name, long value0);
// 
//   public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
// 
//   public abstract void resetForTest();
// 
//   public abstract List<Mark> read(boolean concurrentWrites);
// 
//   public int maxMarks() {
//     return NO_MAX_MARKS;
//   }
// 
//   protected MarkHolder() {}
// }


// Path: testing/src/main/java/io/perfmark/testing/MarkHolderBenchmark.java
import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import java.util.List;
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.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;

/*
 * Copyright 2019 Google LLC
 *
 * Licensed 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 io.perfmark.testing;


@State(Scope.Thread)
public class MarkHolderBenchmark {

  private static final long gen = 1 << Generator.GEN_OFFSET;
  private static final String taskName = "hiya";

  public static final List<String> ASM_FLAGS = List.of(