Skip to content

Commit

Permalink
Update FJ Create
Browse files Browse the repository at this point in the history
  • Loading branch information
axmmisaka committed Aug 20, 2023
1 parent c7e3018 commit a244223
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/benchmark/FJCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

Log.global.level = Log.levels.ERROR;

const N = 400;
const N = 4000;

export class ForkJoinReactor extends Reactor {
// private valueToCalculate;
Expand All @@ -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}`)
}
}
);
Expand All @@ -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);
}
)
}
}

Expand Down

0 comments on commit a244223

Please sign in to comment.