Skip to content

Commit

Permalink
progress on benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
canonic-epicure committed Jul 14, 2020
1 parent 64f6413 commit 297fd3b
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 4 deletions.
9 changes: 9 additions & 0 deletions benchmarks/chrono2/graphful/reject.html
@@ -0,0 +1,9 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="module" src="reject.js"></script>
</head>

<body>
</body>
</html>
89 changes: 89 additions & 0 deletions benchmarks/chrono2/graphful/reject.ts
@@ -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')
8 changes: 4 additions & 4 deletions benchmarks/chrono2/graphless/allocation.ts
Expand Up @@ -30,28 +30,28 @@ export class AllocationBenchmark extends Benchmark<void, void> {
//---------------------------------------------------------------------------------------------------------------------
const runFor = async (atomNum : number = 100000, depCount : number = 1) => {
const chronoGraph2 = AllocationBenchmark.new({
name : `Graphless allocation, total atoms: ${atomNum}, boxes: ${depCount} - ChronoGraph2`,
name : `Data allocation, boxes: ${depCount} - ChronoGraph2, computeds: ${atomNum - depCount}`,
atomNum : atomNum,
depCount : depCount,
graphGen : reactiveDataGeneratorChronoGraph2
})

const mobx = AllocationBenchmark.new({
name : `Graphless allocation, total atoms: ${atomNum}, boxes: ${depCount} - Mobx`,
name : `Data allocation, boxes: ${depCount} - Mobx, computeds: ${atomNum - depCount}`,
atomNum : atomNum,
depCount : depCount,
graphGen : reactiveDataGeneratorMobx
})

const chronoGraph2WithGraph = AllocationBenchmark.new({
name : `Graphless allocation, total atoms: ${atomNum}, boxes: ${depCount} - ChronoGraph2 with graph`,
name : `Data allocation, boxes: ${depCount} - ChronoGraph2 with graph, computeds: ${atomNum - depCount}`,
atomNum : atomNum,
depCount : depCount,
graphGen : new ReactiveDataGeneratorChronoGraph2WithGraph()
})

const chronoGraph1 = AllocationBenchmark.new({
name : `Graphless allocation, total atoms: ${atomNum}, boxes: ${depCount} - ChronoGraph1`,
name : `Data allocation, boxes: ${depCount} - ChronoGraph1, computeds: ${atomNum - depCount}`,
atomNum : atomNum,
depCount : depCount,
graphGen : new ReactiveDataGeneratorChronoGraph1()
Expand Down

0 comments on commit 297fd3b

Please sign in to comment.