From a244223d617ee4366f0c8de3c10d0849ae983bd8 Mon Sep 17 00:00:00 2001 From: Kagamihara Nadeshiko Date: Wed, 2 Aug 2023 03:06:42 -0700 Subject: [PATCH] Update FJ Create --- src/benchmark/FJCreate.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/benchmark/FJCreate.ts b/src/benchmark/FJCreate.ts index 541c969cd..008038dc2 100644 --- a/src/benchmark/FJCreate.ts +++ b/src/benchmark/FJCreate.ts @@ -15,7 +15,7 @@ import { Log.global.level = Log.levels.ERROR; -const N = 400; +const N = 4000; export class ForkJoinReactor extends Reactor { // private valueToCalculate; @@ -30,13 +30,13 @@ export class ForkJoinReactor extends Reactor { const val = inp.get(); if (val == null) { throw new Error(`inp is absent for ${this._name}`) - } + } const sint = Math.sin(val); const res = sint * sint; if (res <= 0) { throw new Error(`this is kinda insane, ${res}`); } else { - console.log(`I am ${this._name}. I finished calculating at time ${this.util.getCurrentLogicalTime()}. Result is ${res}`) + console.log(`I am ${this._name}. I finished calculating after ${this.util.getElapsedLogicalTime()}; ${this.util.getElapsedPhysicalTime()}. Result is ${res}`) } } ); @@ -51,18 +51,20 @@ export class FJCreator extends Reactor { super(parent, "FJCreator"); this.forks = []; this.outp = new OutPort(this); - for (let i = 0; i < N; ++i) { - this.addMutation( - [this.startup], - [], - () => { - const fork = this._uncheckedAddSibling(ForkJoinReactor, `FJReactor ${i}`); - this.forks.push(fork); - this._connect(this.outp, fork.triggerPort); + this.addMutation( + [this.startup], + [this.writable(this.outp)], + function (this, outp) { + console.log("startup triggered!") + for (let i = 0; i < N; ++i) { + const fork = this.getReactor()._uncheckedAddSibling(ForkJoinReactor, `FJReactor ${i}`); + // this.getReactor().forks.push(fork); + this.connect(outp.getPort(), fork.triggerPort); + console.log(`Fork ${i} created at physical time ${this.util.getElapsedPhysicalTime()}`) } - ) - } - this.outp.asWritable(this._getKey(this.outp)).set(69.420); + outp.set(114.514); + } + ) } }