const fileName_1 = "(@effect/core) _src/io/Metrics/operations/trackDurationWith.ts";
import * as tsplus_module_1 from "@tsplus/stdlib/data/Duration";
import * as tsplus_module_2 from "@tsplus/stdlib/collections/HashSet/empty";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/map";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/suspendSucceed";
/**
 * Returns an aspect that will update this metric with the duration that the
 * effect takes to execute. To call this method, you must supply a function
 * that can convert the `Duration` to the input type of this metric.
 *
 * @tsplus fluent ets/Metrics/Metric trackDurationWith
 */

export function trackDurationWith_(self, f) {
  return (effect, __tsplusTrace) => tsplus_module_4.suspendSucceed(() => {
    const startTime = Date.now();
    return tsplus_module_3.map_(effect, a => {
      const endTime = Date.now();
      const duration = new tsplus_module_1.Duration(endTime - startTime);
      self.unsafeUpdate(f(duration), tsplus_module_2.empty());
      return a;
    }, fileName_1 + ":12:24");
  }, fileName_1 + ":10:26");
}
/**
 * Returns an aspect that will update this metric with the duration that the
 * effect takes to execute. To call this method, you must supply a function
 * that can convert the `Duration` to the input type of this metric.
 *
 * @tsplus static ets/Metrics/Metric/Aspects trackDurationWith
 */

export const trackDurationWith = f => self => trackDurationWith_(self, f);
//# sourceMappingURL=trackDurationWith.mjs.map