-
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.
add prettier add better benchmark
- Loading branch information
Showing
18 changed files
with
1,425 additions
and
334 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,3 @@ | ||
dist/ | ||
node_modules | ||
coverage |
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,31 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier", | ||
], | ||
overrides: [ | ||
{ | ||
env: { | ||
node: true, | ||
}, | ||
files: [".eslintrc.{js,cjs}"], | ||
parserOptions: { | ||
sourceType: "script", | ||
}, | ||
}, | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
rules: { | ||
"@typescript-eslint/no-unused-vars": "error", | ||
}, | ||
}; |
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 @@ | ||
dist | ||
node_modules | ||
coverage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Benchmark from "benchmark"; | ||
import { BucketQueue } from "../src"; | ||
import Heap from "heap-js"; | ||
|
||
const suit = new Benchmark.Suite({ | ||
initCount: 1000, | ||
}); | ||
|
||
const rounds = 1_000_000; | ||
const priorityMax = 1_000; | ||
|
||
const items: [string, number][] = []; | ||
|
||
for (let i = 0; i < rounds; i++) { | ||
items.push([`item-${i}`, i % priorityMax]); | ||
} | ||
|
||
const bq = new BucketQueue<string>(); | ||
const heap = new Heap<[string, number]>((a, b) => a[1] - b[1]); | ||
|
||
for (let i = 0; i < items.length; i++) { | ||
bq.push(items[i][0], items[i][1]); | ||
heap.push(items[i]); | ||
} | ||
|
||
suit | ||
.add("BucketQueue", () => { | ||
const i1 = bq.popLowest() as string; | ||
const i2 = bq.popLowest() as string; | ||
const i3 = bq.popLowest() as string; | ||
|
||
bq.push(i3, 0); | ||
bq.push(i2, 0); | ||
bq.push(i1, 0); | ||
}) | ||
.add("Heap", () => { | ||
const i1 = heap.pop() as [string, number]; | ||
const i2 = heap.pop() as [string, number]; | ||
const i3 = heap.pop() as [string, number]; | ||
|
||
heap.push(i3); | ||
heap.push(i2); | ||
heap.push(i1); | ||
}) | ||
.on("cycle", function (e: Event) { | ||
console.log("" + e.target); | ||
}) | ||
.on("complete", function () { | ||
// @ts-expect-error - no error expected | ||
console.log("Fastest is " + this.filter("fastest").map("name")); | ||
}) | ||
.run(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
}; | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
}; |
Oops, something went wrong.