-
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
10 changed files
with
5,698 additions
and
9 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 |
---|---|---|
|
@@ -167,3 +167,5 @@ dist | |
# End of https://www.toptal.com/developers/gitignore/api/node,go | ||
|
||
**/__mocks__/src/ | ||
|
||
benchmarks/src/** |
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,20 @@ | ||
--- | ||
name: "benchmark" | ||
description: "This is a benchmark generator" | ||
prompts: | ||
- type: "base" | ||
name: "name" | ||
message: "Please enter any text." | ||
actions: | ||
- type: "add" | ||
path: "src/moldable/{{.name}}.tsx" | ||
template: "benchmark.tsx" | ||
--- | ||
|
||
# benchmark.tsx | ||
|
||
```tsx | ||
import React from "react"; | ||
|
||
export const {{.name}}: React.FC = (children: { children: React.ReactNode }) => <div>{children}</div>;`, | ||
``` |
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,17 @@ | ||
--- | ||
name: "benchmark" | ||
root: "." | ||
output: "src/scaffdog" | ||
ignore: [] | ||
questions: | ||
name: "Please enter any text." | ||
--- | ||
|
||
# `{{ inputs.name }}.tsx` | ||
|
||
```tsx | ||
import React from "react"; | ||
|
||
export const {{ inputs.name }}: React.FC = (children: { children: React.ReactNode }) => <div>{children}</div>; | ||
``` | ||
|
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,3 @@ | ||
export default { | ||
files: ['*'], | ||
}; |
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,75 @@ | ||
"use strict"; | ||
|
||
const { spawn } = require("child_process"); | ||
const { rimraf } = require("rimraf"); | ||
const { mkdirp } = require("mkdirp"); | ||
|
||
const FILE_NAME = "for-benchmark"; | ||
|
||
const LF = String.fromCharCode(0x0a); // \n | ||
const DOWN = String.fromCharCode(0x1b, 0x5b, 0x42); // ↓ | ||
const ENTER = String.fromCharCode(0x0d); // enter | ||
|
||
async function wait(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
|
||
async function readStream(stream) { | ||
let result = ""; | ||
for await (const line of stream) { | ||
result += line; | ||
} | ||
return result; | ||
} | ||
|
||
async function clear() { | ||
await rimraf("./src"); | ||
await mkdirp("./src"); | ||
} | ||
|
||
(async () => { | ||
const type = process.argv[2]; | ||
|
||
if (type === "plop") { | ||
const plop = spawn("./node_modules/.bin/plop"); | ||
await wait(1000); | ||
plop.stdin.write(FILE_NAME); | ||
await wait(1000); | ||
const plopMeasureStart = performance.now(); | ||
plop.stdin.write(LF); | ||
const plopMeasureEnd = performance.now(); | ||
console.log(`plop: ${plopMeasureEnd - plopMeasureStart}ms`); | ||
} | ||
|
||
if (type === "scaffdog") { | ||
const scaffdog = spawn("./node_modules/.bin/scaffdog", ["generate"]); | ||
await wait(1000); | ||
scaffdog.stdin.write(LF); | ||
await wait(1000); | ||
scaffdog.stdin.write(DOWN); | ||
await wait(1000); | ||
scaffdog.stdin.write(ENTER); | ||
await wait(1000); | ||
scaffdog.stdin.write(FILE_NAME); | ||
await wait(1000); | ||
const scaffdogMeasureStart = performance.now(); | ||
scaffdog.stdin.write(LF); | ||
const scaffdogMeasureEnd = performance.now(); | ||
console.log(`scaffdog: ${scaffdogMeasureEnd - scaffdogMeasureStart}ms`); | ||
} | ||
|
||
if (type === "moldable") { | ||
const moldable = spawn("./node_modules/.bin/moldable"); | ||
await wait(1000); | ||
moldable.stdin.write(LF); | ||
await wait(1000); | ||
moldable.stdin.write(FILE_NAME); | ||
await wait(1000); | ||
const moldableMeasureStart = performance.now(); | ||
moldable.stdin.write(LF); | ||
const moldableMeasureEnd = performance.now(); | ||
console.log(`moldable: ${moldableMeasureEnd - moldableMeasureStart}ms`); | ||
} | ||
|
||
await clear(); | ||
})(); |
Oops, something went wrong.