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
64f6413
commit 297fd3b
Showing
3 changed files
with
102 additions
and
4 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,9 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<script type="module" src="reject.js"></script> | ||
</head> | ||
|
||
<body> | ||
</body> | ||
</html> |
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,89 @@ | ||
import { BoxAbstract, launchIfStandaloneProcess, ReactiveDataBenchmark } from "../graphless/data_generators.js" | ||
import { | ||
ReactiveDataGenerationResultWithGraph, | ||
ReactiveDataGeneratorChronoGraph1, | ||
ReactiveDataGeneratorChronoGraph2WithGraph, | ||
ReactiveDataGeneratorWithGraph | ||
} from "./data_generators.js" | ||
|
||
|
||
//--------------------------------------------------------------------------------------------------------------------- | ||
export class RejectBenchmark extends ReactiveDataBenchmark<ReactiveDataGenerationResultWithGraph> { | ||
atomNum : number = 1000 | ||
depCount : number = 1 | ||
|
||
graphGen : ReactiveDataGeneratorWithGraph<unknown> = undefined | ||
|
||
async setup () : Promise<ReactiveDataGenerationResultWithGraph> { | ||
const me = this | ||
|
||
let boxes : BoxAbstract<number>[] = [] | ||
|
||
const res = { boxes, counter : 0, graph : this.graphGen.graph } | ||
|
||
for (let i = 0; i < this.depCount; i++) { | ||
boxes.push(this.graphGen.box(1)) | ||
} | ||
|
||
for (let i = this.depCount; i < this.atomNum; i++) { | ||
boxes.push(this.graphGen.computedStrict(function () { | ||
res.counter++ | ||
|
||
let sum = 0 | ||
|
||
for (let i = 1; i <= me.depCount; i++) { | ||
sum += boxes[ this - i ].READ() % 10000 | ||
} | ||
|
||
return sum | ||
}, i)) | ||
} | ||
|
||
return res | ||
} | ||
|
||
|
||
cycle (iteration : number, cycle : number, state : ReactiveDataGenerationResultWithGraph) { | ||
const { boxes, graph } = state | ||
|
||
for (let i = 0; i < this.depCount; i++) | ||
boxes[ i ].WRITE((iteration + cycle + i) % 10) | ||
|
||
graph.reject() | ||
} | ||
} | ||
|
||
|
||
//--------------------------------------------------------------------------------------------------------------------- | ||
const runFor = async (atomNum : number = 1000, depCount : number = 1) => { | ||
|
||
const chronoGraph2WithGraph = RejectBenchmark.new({ | ||
name : `Reject in graph, atoms: ${atomNum}, deps depth: ${depCount} - ChronoGraph2 with graph`, | ||
atomNum : atomNum, | ||
depCount : depCount, | ||
graphGen : new ReactiveDataGeneratorChronoGraph2WithGraph() | ||
}) | ||
|
||
const chronoGraph1 = RejectBenchmark.new({ | ||
name : `Reject in graph, atoms: ${atomNum}, deps depth: ${depCount} - ChronoGraph1`, | ||
atomNum : atomNum, | ||
depCount : depCount, | ||
graphGen : new ReactiveDataGeneratorChronoGraph1() | ||
}) | ||
|
||
const runInfoChronoGraph2WithGraph = await chronoGraph2WithGraph.measureTillMaxTime() | ||
const runInfoChronoGraph1 = await chronoGraph1.measureFixed( | ||
runInfoChronoGraph2WithGraph.cyclesCount, runInfoChronoGraph2WithGraph.samples.length | ||
) | ||
|
||
if (runInfoChronoGraph2WithGraph.info.result !== runInfoChronoGraph1.info.result) throw new Error("Results in last box differ") | ||
} | ||
|
||
|
||
export const run = async () => { | ||
await runFor(1000, 1) | ||
await runFor(1000, 10) | ||
await runFor(1000, 100) | ||
} | ||
|
||
launchIfStandaloneProcess(run, 'reject') |
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