effect-io-ai

Package: effect
Module: Console

Console.withTime

Runs an Effect with a console timer, starting the timer before execution and ending it after the Effect completes.

Example (Timing an effect)

import { Console, Effect } from "effect"

const program = Effect.gen(function*() {
  yield* Console.withTime(
    Effect.gen(function*() {
      yield* Effect.sleep("1 second")
      yield* Console.log("Operation completed")
    }),
    "my-operation"
  )
})

Signature

declare const withTime: ((label?: string) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>) & (<A, E, R>(self: Effect.Effect<A, E, R>, label?: string) => Effect.Effect<A, E, R>)

Source

Since v2.0.0