-
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.
src: add bench-node support and use by default
- Loading branch information
Showing
14 changed files
with
148 additions
and
96 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
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
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
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 |
---|---|---|
|
@@ -14,5 +14,5 @@ module.exports = { | |
}, | ||
}, | ||
], | ||
benchmarker: 'tinybench', | ||
benchmarker: 'bench-node', | ||
}; |
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
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 |
---|---|---|
|
@@ -14,5 +14,5 @@ module.exports = { | |
}, | ||
}, | ||
], | ||
benchmarker: 'tinybench', | ||
benchmarker: 'bench-node', | ||
}; |
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 |
---|---|---|
@@ -1,82 +1,85 @@ | ||
const fs = require("node:fs"); | ||
const ts = require("typescript"); | ||
const path = require("node:path"); | ||
const fs = require('node:fs'); | ||
const ts = require('typescript'); | ||
const path = require('node:path'); | ||
const assert = require('node:assert'); | ||
|
||
const filePath = path.join(__dirname, "..", "fixtures", "ts-sample.ts"); | ||
const code = fs.readFileSync(filePath, "utf8"); | ||
const filePath = path.join(__dirname, '..', 'fixtures', 'ts-sample.ts'); | ||
const code = fs.readFileSync(filePath, 'utf8'); | ||
|
||
module.exports = { | ||
name: "typescript", | ||
type: "operation", | ||
operations: [ | ||
{ | ||
name: "transpile", | ||
fn: () => { | ||
ts.transpile( | ||
code, | ||
{ | ||
// CJS Settings | ||
target: ts.ScriptTarget.ESNext, | ||
module: ts.ModuleKind.CommonJS, | ||
moduleResolution: ts.ModuleResolutionKind.Node, | ||
name: 'typescript', | ||
type: 'operation', | ||
operations: [ | ||
{ | ||
name: 'transpile', | ||
fn: () => { | ||
const r = ts.transpile( | ||
code, | ||
{ | ||
// CJS Settings | ||
target: ts.ScriptTarget.ESNext, | ||
module: ts.ModuleKind.CommonJS, | ||
moduleResolution: ts.ModuleResolutionKind.Node, | ||
|
||
// Avoid writing to disk | ||
noEmit: true, | ||
// Avoid writing to disk | ||
noEmit: true, | ||
|
||
// Avoids any checking related code | ||
checkJs: false, | ||
strict: false, | ||
isolatedModules: true, | ||
skipDefaultLibCheck: true, | ||
skipLibCheck: true, | ||
}, | ||
filePath, | ||
); | ||
}, | ||
}, | ||
{ | ||
name: "createSourceFile", | ||
fn: () => { | ||
ts.createSourceFile( | ||
filePath, | ||
code, | ||
ts.ScriptTarget.ESNext, | ||
false, | ||
ts.ScriptKind.TS, | ||
); | ||
}, | ||
}, | ||
{ | ||
name: "getSemanticDiagnostics", | ||
fn: () => { | ||
const program = ts.createProgram({ | ||
rootNames: [filePath], | ||
options: { | ||
// CJS Settings | ||
target: ts.ScriptTarget.ESNext, | ||
module: ts.ModuleKind.CommonJS, | ||
moduleResolution: ts.ModuleResolutionKind.Node, | ||
// Avoids any checking related code | ||
checkJs: false, | ||
strict: false, | ||
isolatedModules: true, | ||
skipDefaultLibCheck: true, | ||
skipLibCheck: true, | ||
}, | ||
filePath, | ||
); | ||
assert.ok(r); | ||
}, | ||
}, | ||
{ | ||
name: 'createSourceFile', | ||
fn: () => { | ||
const r = ts.createSourceFile( | ||
filePath, | ||
code, | ||
ts.ScriptTarget.ESNext, | ||
false, | ||
ts.ScriptKind.TS, | ||
); | ||
assert.ok(r); | ||
}, | ||
}, | ||
{ | ||
name: 'getSemanticDiagnostics', | ||
fn: () => { | ||
const program = ts.createProgram({ | ||
rootNames: [filePath], | ||
options: { | ||
// CJS Settings | ||
target: ts.ScriptTarget.ESNext, | ||
module: ts.ModuleKind.CommonJS, | ||
moduleResolution: ts.ModuleResolutionKind.Node, | ||
|
||
// also loads and checks js | ||
allowJs: true, | ||
checkJs: true, | ||
// also loads and checks js | ||
allowJs: true, | ||
checkJs: true, | ||
|
||
// test types | ||
strict: true, | ||
// test types | ||
strict: true, | ||
|
||
// Avoid writing to disk | ||
noEmit: true, | ||
// Avoid writing to disk | ||
noEmit: true, | ||
|
||
// Loads external files | ||
isolatedModules: true, | ||
skipDefaultLibCheck: false, | ||
skipLibCheck: false, | ||
}, | ||
}); | ||
// Loads external files | ||
isolatedModules: true, | ||
skipDefaultLibCheck: false, | ||
skipLibCheck: false, | ||
}, | ||
}); | ||
|
||
program.getSemanticDiagnostics(program.getSourceFile(filePath)); | ||
}, | ||
}, | ||
], | ||
benchmarker: "tinybench", | ||
program.getSemanticDiagnostics(program.getSourceFile(filePath)); | ||
}, | ||
}, | ||
], | ||
benchmarker: 'tinybench', | ||
}; |
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 |
---|---|---|
|
@@ -22,5 +22,5 @@ module.exports = { | |
}, | ||
}, | ||
], | ||
benchmarker: 'tinybench', | ||
benchmarker: 'bench-node', | ||
}; |
Oops, something went wrong.