forked from topology-foundation/ts-topology
-
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
1 parent
c476658
commit 79c2894
Showing
5 changed files
with
111 additions
and
26 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 |
---|---|---|
@@ -1 +1 @@ | ||
export const VERSION = "0.2.1-4"; | ||
export const VERSION = "0.2.1"; |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Benchmark from "benchmark"; | ||
import { AddWinsSet } from "../../blueprints/src/AddWinsSet/index.js"; | ||
import { TopologyObject } from "../src/index.js"; | ||
|
||
function benchmarkForAddWinSet( | ||
name: string, | ||
numCROs: number, | ||
verticesPerCRO: number, | ||
mergeFn: boolean, | ||
) { | ||
return suite.add(name, () => { | ||
const objects: TopologyObject[] = []; | ||
for (let i = 0; i < numCROs; i++) { | ||
const obj: TopologyObject = new TopologyObject( | ||
`peer${i + 1}`, | ||
new AddWinsSet<number>(), | ||
); | ||
const cro = obj.cro as AddWinsSet<number>; | ||
for (let j = 0; j < verticesPerCRO; j++) { | ||
if (i % 3 === 2) { | ||
cro.add(j); | ||
cro.remove(j); | ||
} else if (i % 3 === 1) { | ||
cro.remove(j); | ||
cro.add(j); | ||
} else { | ||
cro.add(j); | ||
} | ||
} | ||
objects.push(obj); | ||
} | ||
|
||
if (mergeFn) { | ||
for (let i = 0; i < objects.length; i++) { | ||
for (let j = 0; j < objects.length; j++) { | ||
if (i !== j) { | ||
objects[i].merge(objects[j].hashGraph.getAllVertices()); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
const suite = new Benchmark.Suite(); | ||
|
||
benchmarkForAddWinSet("Create HashGraph with 1000 vertices", 1, 1000, false); | ||
|
||
benchmarkForAddWinSet( | ||
"Create 2 CROs (1000 vertices each) and Merge", | ||
2, | ||
1000, | ||
true, | ||
); | ||
|
||
suite | ||
.on("cycle", (event) => { | ||
console.log(String(event.target)); | ||
}) | ||
.on("complete", function () { | ||
console.log(`Fastest is ${this.filter("fastest").map("name")}`); | ||
}) | ||
.run({ async: true }); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.