Performance

Measured against Effect, in the open.

10 everyday operations, each written the way its library's docs write it, timed whenever functype's code changes on main and every week. Where the two are level, or Effect is faster, this page says so.

7faster
1about the same
2slower

functype main at 019d8b7 · Effect 4.1.5 · Node 24.20.0 · 2026-11-23

Data types

Option: build, map, getOrElse

1.2× slower
functype5.8 ns
Effect4.8 ns
Show the code

Effect's time over functype's, in each of the 5 processes: from 0.83 to 0.94.

functype
(i) => Some(i).map(inc).getOrElse(() => 0)
Effect
(i) => Option.getOrElse(Option.map(Option.some(i), inc), () => 0)

Either (Effect's Result): build, map, getOrElse

1.3× faster
functype4.0 ns
Effect5.2 ns
Show the code

Effect's time over functype's, in each of the 5 processes: from 1.13 to 1.32.

functype
(i) => Right(i).map(inc).getOrElse(() => 0)
Effect
(i) => Result.getOrElse(Result.map(Result.succeed(i), inc), () => 0)

List (Effect's Array module): 10 items, map, filter

3.0× slower
functype133 ns
Effect45.1 ns
Show the code

Effect's time over functype's, in each of the 5 processes: from 0.32 to 0.34.

functype
(i) => List(items).map((x) => x + i).filter((x) => x % 2 === 0).size
Effect
(i) => Arr.filter(Arr.map(items, (x) => x + i), (x) => x % 2 === 0).length

Effects, run synchronously

Build, map and run an effect

5.7× faster
functype63.9 ns
Effect366 ns
Show the code

Effect's time over functype's, in each of the 5 processes: from 5.58 to 6.33.

functype
(i) => IO.succeed(i).map(inc).runSyncOrThrow()
Effect
(i) => Effect.runSync(Effect.map(Effect.succeed(i), inc))

50 flatMaps, built and run

1.6× faster
functype2.74 µs
Effect4.42 µs
Show the code

Effect's time over functype's, in each of the 5 processes: from 1.57 to 1.71.

functype
(i) => {
  let io = IO.succeed(i)
  for (let k = 0; k < 50; k++) io = io.flatMap((x) => IO.succeed(x + 1))
  return io.runSyncOrThrow()
}
Effect
(i) => {
  let ef = Effect.succeed(i)
  for (let k = 0; k < 50; k++) ef = Effect.flatMap(ef, (x) => Effect.succeed(x + 1))
  return Effect.runSync(ef)
}

A generator with 10 yields

About the same
functype1.59 µs
Effect1.67 µs
Show the code

Effect's time over functype's, in each of the 5 processes: from 0.99 to 1.07.

functype
(i) =>
IO.gen(function* () {
  let x = i
  for (let k = 0; k < 10; k++) x = yield* IO.succeed(x + 1)
  return x
}).runSyncOrThrow()
Effect
(i) =>
Effect.runSync(
  Effect.gen(function* () {
    let x = i
    for (let k = 0; k < 10; k++) x = yield* Effect.succeed(x + 1)
    return x
  }),
)

Fail, then recover by tag

4.9× faster
functype104 ns
Effect514 ns
Show the code

Effect's time over functype's, in each of the 5 processes: from 4.69 to 5.06.

functype
(i) =>
IO.fail(new Boom())
  .catchTag("Boom", () => IO.succeed(i))
  .runSyncOrThrow()
Effect
(i) => Effect.runSync(Effect.catchTag(Effect.fail(new Boom()), "Boom", () => Effect.succeed(i)))

Read a service, provide it, run

2.3× faster
functype229 ns
Effect532 ns
Show the code

Effect's time over functype's, in each of the 5 processes: from 2.29 to 2.36.

functype
(i) =>
IO.service(DbF)
  .map((d) => d.k + i)
  .provideService(DbF, db)
  .runSyncOrThrow()
Effect
(i) =>
Effect.runSync(
  Effect.provideService(
    Effect.map(DbE, (d) => d.k + i),
    DbE,
    db,
  ),
)

Effects, run asynchronously

Wrap a promise, map, run

1.5× faster
functype306 ns
Effect463 ns
Show the code

Effect's time over functype's, in each of the 5 processes: from 1.42 to 1.55.

functype
(i) =>
IO.async(() => Promise.resolve(i))
  .map(inc)
  .runOrThrow()
Effect
(i) =>
Effect.runPromise(
  Effect.map(
    Effect.promise(() => Promise.resolve(i)),
    inc,
  ),
)

50 steps, run as a promise

1.2× faster
functype3.47 µs
Effect4.33 µs
Show the code

Effect's time over functype's, in each of the 5 processes: from 1.22 to 1.28.

functype
(i) => {
  let io = IO.succeed(i)
  for (let k = 0; k < 50; k++) io = io.flatMap((x) => IO.succeed(x + 1))
  return io.runOrThrow()
}
Effect
(i) => {
  let ef = Effect.succeed(i)
  for (let k = 0; k < 50; k++) ef = Effect.flatMap(ef, (x) => Effect.succeed(x + 1))
  return Effect.runPromise(ef)
}

What an app ships

The same small program in each library, bundled by esbuild for the browser, minified, then gzipped.

An Option-only app

1.2× smaller
functype5.7 KB
Effect7.0 KB
The program
functype
import { Option } from "functype"
console.log(Option(1).map((x) => x + 1).getOrElse(() => 0))
Effect
import { Option } from "effect"
console.log(Option.getOrElse(Option.map(Option.some(1), (x) => x + 1), () => 0))

An app with effects, Either, Option and List

3.2× smaller
functype11.6 KB
Effect37.6 KB
The program
functype
import { IO, Either, Option, List } from "functype"
const p = IO.gen(function* () { const a = yield* IO.succeed(1); return a + 1 }).catchTag("X", () => IO.succeed(0))
console.log(p.runSyncOrThrow(), Either.right(1).map((x) => x), Option(1), List([1]).map((x) => x))
Effect
import { Effect, Result, Option, Array as Arr } from "effect"
const p = Effect.catchTag(Effect.gen(function* () { const a = yield* Effect.succeed(1); return a + 1 }), "X", () => Effect.succeed(0))
console.log(Effect.runSync(p), Result.map(Result.succeed(1), (x) => x), Option.some(1), Arr.map([1], (x) => x))

How it's measured

Shared setup

const inc = (x) => x + 1
const items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
class Boom { _tag = "Boom" }
const DbF = Tag("Db")                            // functype
class DbE extends Context.Service()("Db") {}     // Effect
const db = { k: 3 }

Run it yourself

pnpm install
pnpm -F functype build
pnpm -F functype-bench bench

The cases are in packages/bench/src/cases.mjs. A case that's unfair to either library is a bug: open an issue.