-
Notifications
You must be signed in to change notification settings - Fork 5
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
41 changed files
with
1,325 additions
and
1,184 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"style": { | ||
"noParameterAssign": "off" | ||
} | ||
} | ||
}, | ||
"formatter": { | ||
"enabled": true | ||
}, | ||
"files": { | ||
"ignore": [ | ||
"examples/deleting-properties/node.js" | ||
] | ||
} | ||
} |
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,25 +1,25 @@ | ||
const { Suite } = require('../../lib'); | ||
const { Suite } = require("../../lib"); | ||
|
||
const suite = new Suite(); | ||
|
||
suite | ||
.add(`new Uint32Array(1024)`, function () { | ||
return new Uint32Array(1024); | ||
}) | ||
.add(`new Uint32Array(1024) with 10 repetitions`, {repeatSuite: 10}, function () { | ||
return new Uint32Array(1024); | ||
}) | ||
.add(`[Managed] new Uint32Array(1024)`, function (timer) { | ||
const assert = require('node:assert'); | ||
.add("new Uint32Array(1024)", () => new Uint32Array(1024)) | ||
.add( | ||
"new Uint32Array(1024) with 10 repetitions", | ||
{ repeatSuite: 10 }, | ||
() => new Uint32Array(1024), | ||
) | ||
.add("[Managed] new Uint32Array(1024)", (timer) => { | ||
const assert = require("node:assert"); | ||
|
||
let r; | ||
let r; | ||
|
||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
r = new Uint32Array(1024); | ||
} | ||
timer.end(timer.count); | ||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
r = new Uint32Array(1024); | ||
} | ||
timer.end(timer.count); | ||
|
||
assert.ok(r); | ||
}) | ||
.run(); | ||
assert.ok(r); | ||
}) | ||
.run(); |
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,67 +1,86 @@ | ||
const crypto = require('node:crypto'); | ||
const { readFileSync } = require('fs'); | ||
const { Suite } = require('../../lib'); | ||
const crypto = require("node:crypto"); | ||
const { readFileSync } = require("node:fs"); | ||
const { Suite } = require("../../lib"); | ||
|
||
const rsaPrivateKey = readFileSync(`${__dirname}/private-key.pem`, 'utf-8'); | ||
const rsaPublicKey = readFileSync(`${__dirname}/public-key.pem`, 'utf-8'); | ||
const rsaPrivateKey = readFileSync(`${__dirname}/private-key.pem`, "utf-8"); | ||
const rsaPublicKey = readFileSync(`${__dirname}/public-key.pem`, "utf-8"); | ||
|
||
const thing = 'hello world'; | ||
const algorithm = 'RSA-SHA256'; | ||
const signature = crypto.createSign(algorithm).update(thing).sign(rsaPrivateKey, 'base64'); | ||
const thing = "hello world"; | ||
const algorithm = "RSA-SHA256"; | ||
const signature = crypto | ||
.createSign(algorithm) | ||
.update(thing) | ||
.sign(rsaPrivateKey, "base64"); | ||
|
||
const suite = new Suite(); | ||
|
||
suite | ||
.add(`crypto.createVerify('${algorithm}')`, function () { | ||
var verifier = crypto.createVerify(algorithm); | ||
verifier.update(thing); | ||
verifier.verify(rsaPublicKey, signature, 'base64'); | ||
}) | ||
.add(`crypto.verify('${algorithm}')`, function () { | ||
crypto.verify(algorithm, thing, rsaPublicKey, Buffer.from(signature, 'base64')); | ||
}) | ||
.add(`[Managed] crypto.createVerify('RSA-SHA256')`, function (timer) { | ||
const crypto = require('node:crypto'); | ||
const { readFileSync } =require('node:fs'); | ||
const assert = require('node:assert'); | ||
.add(`crypto.createVerify('${algorithm}')`, () => { | ||
const verifier = crypto.createVerify(algorithm); | ||
verifier.update(thing); | ||
verifier.verify(rsaPublicKey, signature, "base64"); | ||
}) | ||
.add(`crypto.verify('${algorithm}')`, () => { | ||
crypto.verify( | ||
algorithm, | ||
thing, | ||
rsaPublicKey, | ||
Buffer.from(signature, "base64"), | ||
); | ||
}) | ||
.add(`[Managed] crypto.createVerify('RSA-SHA256')`, (timer) => { | ||
const crypto = require("node:crypto"); | ||
const { readFileSync } = require("node:fs"); | ||
const assert = require("node:assert"); | ||
|
||
const rsaPrivateKey = readFileSync(`${__dirname}/private-key.pem`, 'utf-8'); | ||
const rsaPublicKey = readFileSync(`${__dirname}/public-key.pem`, 'utf-8'); | ||
const rsaPrivateKey = readFileSync(`${__dirname}/private-key.pem`, "utf-8"); | ||
const rsaPublicKey = readFileSync(`${__dirname}/public-key.pem`, "utf-8"); | ||
|
||
const thing = 'hello world' | ||
const signature = crypto.createSign('RSA-SHA256').update(thing).sign(rsaPrivateKey, 'base64') | ||
const thing = "hello world"; | ||
const signature = crypto | ||
.createSign("RSA-SHA256") | ||
.update(thing) | ||
.sign(rsaPrivateKey, "base64"); | ||
|
||
let verifier; | ||
let verifier; | ||
|
||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
verifier = crypto.createVerify('RSA-SHA256') | ||
verifier.update(thing) | ||
verifier.verify(rsaPublicKey, signature, 'base64') | ||
} | ||
timer.end(timer.count); | ||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
verifier = crypto.createVerify("RSA-SHA256"); | ||
verifier.update(thing); | ||
verifier.verify(rsaPublicKey, signature, "base64"); | ||
} | ||
timer.end(timer.count); | ||
|
||
assert.ok(verifier); | ||
}) | ||
.add(`[Managed] crypto.verify('RSA-SHA256')`, function (timer) { | ||
const crypto = require('node:crypto'); | ||
const { readFileSync } = require('node:fs'); | ||
const assert = require('node:assert'); | ||
assert.ok(verifier); | ||
}) | ||
.add(`[Managed] crypto.verify('RSA-SHA256')`, (timer) => { | ||
const crypto = require("node:crypto"); | ||
const { readFileSync } = require("node:fs"); | ||
const assert = require("node:assert"); | ||
|
||
const rsaPrivateKey = readFileSync(`${__dirname}/private-key.pem`, 'utf-8'); | ||
const rsaPublicKey = readFileSync(`${__dirname}/public-key.pem`, 'utf-8'); | ||
const rsaPrivateKey = readFileSync(`${__dirname}/private-key.pem`, "utf-8"); | ||
const rsaPublicKey = readFileSync(`${__dirname}/public-key.pem`, "utf-8"); | ||
|
||
const thing = 'hello world' | ||
const signature = crypto.createSign('RSA-SHA256').update(thing).sign(rsaPrivateKey, 'base64') | ||
const thing = "hello world"; | ||
const signature = crypto | ||
.createSign("RSA-SHA256") | ||
.update(thing) | ||
.sign(rsaPrivateKey, "base64"); | ||
|
||
let r; | ||
let r; | ||
|
||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
r = crypto.verify('RSA-SHA256', thing, rsaPublicKey, Buffer.from(signature, 'base64')); | ||
} | ||
timer.end(timer.count); | ||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
r = crypto.verify( | ||
"RSA-SHA256", | ||
thing, | ||
rsaPublicKey, | ||
Buffer.from(signature, "base64"), | ||
); | ||
} | ||
timer.end(timer.count); | ||
|
||
assert.ok(r); | ||
}) | ||
.run(); | ||
assert.ok(r); | ||
}) | ||
.run(); |
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,8 +1,8 @@ | ||
const { Suite } = require('../../lib'); | ||
const { Suite } = require("../../lib"); | ||
|
||
const suite = new Suite(); | ||
|
||
suite | ||
.add(`empty`, function () {}) | ||
.add(`empty async`, async function () {}) | ||
.run(); | ||
.add("empty", () => {}) | ||
.add("empty async", async () => {}) | ||
.run(); |
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,48 +1,48 @@ | ||
const { Suite } = require('../../lib'); | ||
const { readFile } = require('node:fs/promises'); | ||
const { resolve } = require('node:path'); | ||
const { Suite } = require("../../lib"); | ||
const { readFile } = require("node:fs/promises"); | ||
const { resolve } = require("node:path"); | ||
|
||
const suite = new Suite(); | ||
|
||
const sampleFile = resolve(__dirname, 'sample-file.txt'); | ||
const sampleFile = resolve(__dirname, "sample-file.txt"); | ||
|
||
suite | ||
.add('readFile', async function () { | ||
const r = await readFile(sampleFile); | ||
}) | ||
.add('readFile utf-8', async function () { | ||
const r = await readFile(sampleFile, 'utf-8'); | ||
}) | ||
.add('[managed] readFile', async function (timer) { | ||
const { readFile } = require('node:fs/promises'); | ||
const { resolve } = require('node:path'); | ||
const assert = require('node:assert'); | ||
|
||
const sampleFile = resolve(__dirname, 'sample-file.txt'); | ||
let r; | ||
|
||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
r = await readFile(sampleFile); | ||
} | ||
timer.end(timer.count); | ||
|
||
assert.ok(r); | ||
}) | ||
.add('[managed] readFile utf-8', async function (timer) { | ||
const { readFile } = require('node:fs/promises'); | ||
const { resolve } = require('node:path'); | ||
const assert = require('node:assert'); | ||
|
||
const sampleFile = resolve(__dirname, 'sample-file.txt'); | ||
let r; | ||
|
||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
r = await readFile(sampleFile, 'utf-8'); | ||
} | ||
timer.end(timer.count); | ||
|
||
assert.ok(r); | ||
}) | ||
.run(); | ||
.add("readFile", async () => { | ||
const r = await readFile(sampleFile); | ||
}) | ||
.add("readFile utf-8", async () => { | ||
const r = await readFile(sampleFile, "utf-8"); | ||
}) | ||
.add("[managed] readFile", async (timer) => { | ||
const { readFile } = require("node:fs/promises"); | ||
const { resolve } = require("node:path"); | ||
const assert = require("node:assert"); | ||
|
||
const sampleFile = resolve(__dirname, "sample-file.txt"); | ||
let r; | ||
|
||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
r = await readFile(sampleFile); | ||
} | ||
timer.end(timer.count); | ||
|
||
assert.ok(r); | ||
}) | ||
.add("[managed] readFile utf-8", async (timer) => { | ||
const { readFile } = require("node:fs/promises"); | ||
const { resolve } = require("node:path"); | ||
const assert = require("node:assert"); | ||
|
||
const sampleFile = resolve(__dirname, "sample-file.txt"); | ||
let r; | ||
|
||
timer.start(); | ||
for (let i = 0; i < timer.count; i++) { | ||
r = await readFile(sampleFile, "utf-8"); | ||
} | ||
timer.end(timer.count); | ||
|
||
assert.ok(r); | ||
}) | ||
.run(); |
Oops, something went wrong.