-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
459 additions
and
284 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Test Deno | ||
on: | ||
push: | ||
branches: "main" | ||
paths-ignore: | ||
- .gitignore | ||
- LICENSE | ||
- README.md | ||
- "!.github/workflows/test-deno.yml" | ||
pull_request: | ||
branches: "main" | ||
paths: | ||
- .gitignore | ||
- LICENSE | ||
- README.md | ||
- "!.github/workflows/test-deno.yml" | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
jobs: | ||
test-deno: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
cache: npm | ||
- uses: denoland/setup-deno@v1 | ||
- run: deno eval --node-modules-dir 'import "npm:[email protected]"' | ||
- run: npm ci | ||
- run: npm run test:deno | ||
- run: npm run bench:deno |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ jobs: | |
cache: npm | ||
- run: npm ci | ||
- run: npm run test:node | ||
- run: npm run bench:node |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { writeFile } from "node:fs/promises"; | ||
import { Bench } from "tinybench"; | ||
import { createWorker } from "await-sync"; | ||
import makeSynchronous from "make-synchronous"; | ||
import { createSyncFn } from "synckit"; | ||
import redlet from "../src/redlet-node.js"; | ||
import { unlinkSync } from "node:fs"; | ||
|
||
const bench = new Bench({ time: 3000 }); | ||
|
||
// prettier-ignore | ||
await writeFile("synckit-runAsWorker (1).mjs", ` | ||
import { runAsWorker } from "synckit"; | ||
runAsWorker(() => {}); | ||
`); | ||
process.on("exit", () => { | ||
unlinkSync("synckit-runAsWorker (1).mjs"); | ||
}); | ||
const synckit_noop = createSyncFn( | ||
process.cwd() + "/synckit-runAsWorker (1).mjs" | ||
); | ||
bench.add("noop: synckit", () => { | ||
synckit_noop(); | ||
}); | ||
|
||
const tinylet_noop = redlet(() => {}); | ||
bench.add("noop: tinylet", () => { | ||
tinylet_noop(); | ||
}); | ||
|
||
const await_sync_noop = createWorker()(() => {}); | ||
bench.add("noop: await-sync", () => { | ||
await_sync_noop(); | ||
}); | ||
|
||
const make_synchronous_noop = makeSynchronous(() => {}); | ||
bench.add("noop: make-synchronous", () => { | ||
make_synchronous_noop(); | ||
}); | ||
|
||
await bench.warmup(); | ||
await bench.run(); | ||
console.table(bench.table()); | ||
process.exit(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Bench } from "npm:tinybench"; | ||
import redlet from "../src/redlet-deno+default.js"; | ||
import { createWorker } from "npm:await-sync"; | ||
import { writeFile } from "node:fs/promises"; | ||
import { unlinkSync } from "node:fs"; | ||
import process from "node:process"; | ||
|
||
await writeFile("test.log", "test\n".repeat(1000)); | ||
process.on("exit", () => { | ||
unlinkSync("test.log"); | ||
}); | ||
const testFile = process.cwd() + "/test.log"; | ||
|
||
const bench = new Bench({ time: 3000 }); | ||
|
||
const tinylet_readFile = redlet(async (f) => { | ||
const { readFile } = await import("node:fs/promises"); | ||
return await readFile(f); | ||
}); | ||
bench.add("tinylet readFile()", () => { | ||
tinylet_readFile(testFile); | ||
}); | ||
|
||
const await_sync_readFile = createWorker()(async (f) => { | ||
const { readFile } = await import("node:fs/promises"); | ||
return await readFile(f); | ||
}); | ||
bench.add("await-sync readFile()", () => { | ||
await_sync_readFile(testFile); | ||
}); | ||
|
||
await bench.warmup(); | ||
await bench.run(); | ||
console.table(bench.table()); | ||
process.exit(); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Bench } from "npm:tinybench"; | ||
import redlet from "../src/redlet-deno+default.js"; | ||
import greenlet from "../src/greenlet-deno+default.js"; | ||
import process from "node:process"; | ||
|
||
const bench = new Bench({ time: 1000 }); | ||
|
||
const g = greenlet((a, b) => a + b); | ||
const r = redlet((a, b) => a + b); | ||
|
||
bench.add("greenlet: 200x 'A' + 200x 'B' concat", async () => { | ||
await g("A".repeat(200), "B".repeat(200)); | ||
}); | ||
|
||
bench.add("redlet: 200x 'A' + 200x 'B' concat", () => { | ||
r("A".repeat(200), "B".repeat(200)); | ||
}); | ||
|
||
bench.add("greenlet: 1000x 'A' + 1000x 'B' concat", async () => { | ||
await g("A".repeat(1000), "B".repeat(1000)); | ||
}); | ||
|
||
bench.add("redlet: 1000x 'A' + 1000x 'B' concat", () => { | ||
r("A".repeat(1000), "B".repeat(1000)); | ||
}); | ||
|
||
bench.add("greenlet: 10kb 'A' + 10kb 'B' concat", async () => { | ||
await g("A".repeat(10 * 1024), "B".repeat(10 * 1024)); | ||
}); | ||
|
||
bench.add("redlet: 10kb 'A' + 10kb 'B' concat", () => { | ||
r("A".repeat(10 * 1024), "B".repeat(10 * 1024)); | ||
}); | ||
|
||
await bench.run(); | ||
console.table(bench.table()); | ||
process.exit(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Bench } from "tinybench"; | ||
import { redlet, greenlet } from "../src/index.js"; | ||
|
||
const bench = new Bench({ time: 1000 }); | ||
|
||
const g = greenlet((a, b) => a + b); | ||
const r = redlet((a, b) => a + b); | ||
|
||
bench.add("greenlet: 200x 'A' + 200x 'B' concat", async () => { | ||
await g("A".repeat(200), "B".repeat(200)); | ||
}); | ||
|
||
bench.add("redlet: 200x 'A' + 200x 'B' concat", () => { | ||
r("A".repeat(200), "B".repeat(200)); | ||
}); | ||
|
||
bench.add("greenlet: 1000x 'A' + 1000x 'B' concat", async () => { | ||
await g("A".repeat(1000), "B".repeat(1000)); | ||
}); | ||
|
||
bench.add("redlet: 1000x 'A' + 1000x 'B' concat", () => { | ||
r("A".repeat(1000), "B".repeat(1000)); | ||
}); | ||
|
||
bench.add("greenlet: 10kb 'A' + 10kb 'B' concat", async () => { | ||
await g("A".repeat(10 * 1024), "B".repeat(10 * 1024)); | ||
}); | ||
|
||
bench.add("redlet: 10kb 'A' + 10kb 'B' concat", () => { | ||
r("A".repeat(10 * 1024), "B".repeat(10 * 1024)); | ||
}); | ||
|
||
await bench.run(); | ||
console.table(bench.table()); | ||
process.exit(); |
Oops, something went wrong.