Skip to content

Commit a244223

Browse files
committed
Update FJ Create
1 parent c7e3018 commit a244223

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/benchmark/FJCreate.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515

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

18-
const N = 400;
18+
const N = 4000;
1919

2020
export class ForkJoinReactor extends Reactor {
2121
// private valueToCalculate;
@@ -30,13 +30,13 @@ export class ForkJoinReactor extends Reactor {
3030
const val = inp.get();
3131
if (val == null) {
3232
throw new Error(`inp is absent for ${this._name}`)
33-
}
33+
}
3434
const sint = Math.sin(val);
3535
const res = sint * sint;
3636
if (res <= 0) {
3737
throw new Error(`this is kinda insane, ${res}`);
3838
} else {
39-
console.log(`I am ${this._name}. I finished calculating at time ${this.util.getCurrentLogicalTime()}. Result is ${res}`)
39+
console.log(`I am ${this._name}. I finished calculating after ${this.util.getElapsedLogicalTime()}; ${this.util.getElapsedPhysicalTime()}. Result is ${res}`)
4040
}
4141
}
4242
);
@@ -51,18 +51,20 @@ export class FJCreator extends Reactor {
5151
super(parent, "FJCreator");
5252
this.forks = [];
5353
this.outp = new OutPort(this);
54-
for (let i = 0; i < N; ++i) {
55-
this.addMutation(
56-
[this.startup],
57-
[],
58-
() => {
59-
const fork = this._uncheckedAddSibling(ForkJoinReactor, `FJReactor ${i}`);
60-
this.forks.push(fork);
61-
this._connect(this.outp, fork.triggerPort);
54+
this.addMutation(
55+
[this.startup],
56+
[this.writable(this.outp)],
57+
function (this, outp) {
58+
console.log("startup triggered!")
59+
for (let i = 0; i < N; ++i) {
60+
const fork = this.getReactor()._uncheckedAddSibling(ForkJoinReactor, `FJReactor ${i}`);
61+
// this.getReactor().forks.push(fork);
62+
this.connect(outp.getPort(), fork.triggerPort);
63+
console.log(`Fork ${i} created at physical time ${this.util.getElapsedPhysicalTime()}`)
6264
}
63-
)
64-
}
65-
this.outp.asWritable(this._getKey(this.outp)).set(69.420);
65+
outp.set(114.514);
66+
}
67+
)
6668
}
6769
}
6870

0 commit comments

Comments
 (0)