import { getCurrentSuite } from "../../../@vitest/runner/dist/index.js";
import { a as createChainable } from "../../../@vitest/runner/dist/chunk-tasks.js";
import { noop } from "../../../@vitest/utils/dist/helpers.js";
import { g as getWorkerState } from "./utils.BX5Fg8C4.js";
const benchFns = /* @__PURE__ */ new WeakMap();
const benchOptsMap = /* @__PURE__ */ new WeakMap();
createBenchmark(function(name, fn = noop, options = {}) {
  if (getWorkerState().config.mode !== "benchmark") throw new Error("`bench()` is only available in benchmark mode.");
  const task = getCurrentSuite().task(formatName(name), {
    ...this,
    meta: { benchmark: true }
  });
  benchFns.set(task, fn);
  benchOptsMap.set(task, options);
  if (!this.todo && task.mode === "todo") task.mode = "run";
});
function createBenchmark(fn) {
  const benchmark = createChainable([
    "skip",
    "only",
    "todo"
  ], fn);
  benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
  benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
  return benchmark;
}
function formatName(name) {
  return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
}
//# sourceMappingURL=benchmark.D0SlKNbZ.js.map
