Created
May 8, 2026 10:49
-
-
Save tim-smart/49aee31e9fe80719cdb17e58e4be156b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { NodeRuntime, NodeServices } from "@effect/platform-node" | |
| import { Console, Effect, Stream } from "effect" | |
| import { ChildProcess } from "effect/unstable/process" | |
| import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner" | |
| Effect.gen(function*() { | |
| const spawner = yield* ChildProcessSpawner | |
| const handle = yield* spawner.spawn(ChildProcess.make`git diff`) | |
| yield* handle.stdout.pipe( | |
| Stream.decodeText, | |
| Stream.mkString | |
| ) | |
| }).pipe( | |
| Console.withTime("effect"), | |
| Effect.scoped, | |
| Effect.provide(NodeServices.layer), | |
| NodeRuntime.runMain | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as CP from "node:child_process" | |
| async function main() { | |
| console.time("node") | |
| const handle = CP.spawn("git", ["diff"]) | |
| handle.stdout.setEncoding("utf8") | |
| let out = "" | |
| await handle.stdout.forEach((data) => { | |
| out += data | |
| }) | |
| console.timeEnd("node") | |
| } | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| effect-smol git(main) node scratchpad/effect.ts | |
| effect: 13.195ms | |
| effect-smol git(main) node scratchpad/node.ts | |
| node: 13.407ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment