Skip to content

Commit 38fe10d

Browse files
committed
Big Benchmark (add runner)
1 parent e21f9f9 commit 38fe10d

File tree

2 files changed

+43
-38
lines changed

2 files changed

+43
-38
lines changed

TS/Savina/src/micro/Big.lf

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ target TypeScript {
88
fast: true
99
};
1010

11-
main reactor Big(limit:number(25000)) {
12-
13-
state startTime:time;
11+
import BenchmarkRunner from "../BenchmarkRunner.lf";
12+
13+
main reactor Big(numIterations:number(12), limit:number(25000)) {
14+
15+
runner = new BenchmarkRunner(numIterations = numIterations);
1416

1517
s = new Sink();
1618

@@ -19,6 +21,9 @@ main reactor Big(limit:number(25000)) {
1921
p3 = new PingPonger(limit = limit, index = 3);
2022
p4 = new PingPonger(limit = limit, index = 4);
2123
p5 = new PingPonger(limit = limit, index = 5);
24+
25+
(runner.start)+ -> p1.start, p2.start, p3.start, p4.start, p5.start;
26+
s.stopTimer -> runner.finish;
2227

2328
p1.done -> s.done1;
2429
p2.done -> s.done2;
@@ -75,30 +80,14 @@ main reactor Big(limit:number(25000)) {
7580
p5.respond2 -> p2.ack5;
7681
p5.respond3 -> p3.ack5;
7782
p5.respond4 -> p4.ack5;
78-
79-
reaction(startup) -> p1.start, p2.start, p3.start, p4.start, p5.start {=
80-
startTime = util.getCurrentPhysicalTime();
81-
p1.start = null;
82-
p2.start = null;
83-
p3.start = null;
84-
p4.start = null;
85-
p5.start = null;
86-
=}
87-
88-
reaction(s.stopTimer) {=
89-
if (startTime) {
90-
let elapsedTime = util.getCurrentPhysicalTime().subtract(startTime);
91-
console.log("Elapsed time: " + elapsedTime);
92-
util.requestStop();
93-
}
94-
=}
83+
9584
}
9685

9786

9887
// Index is the number of this ping ponger and must be set
9988
// to x with 1 <= x <= numberOfActors, when the instance is created.
10089
reactor PingPonger(limit:number(25000), index:number(-1), numberOfActors:number(5)) {
101-
input start:null;
90+
input start:boolean;
10291
output done:null;
10392
output send1:string;
10493
output send2:string;
@@ -134,61 +123,62 @@ reactor PingPonger(limit:number(25000), index:number(-1), numberOfActors:number(
134123
switch (sendIndex) {
135124
case 1: {
136125
send1 = "ping";
137-
// console.log(`In index: ${index}, pinging: 1 `);
126+
// console.log(`In index: ${index}, pinging: 1 `);
138127
break;
139128
}
140129
case 2: {
141130
send2 = "ping";
142-
// console.log(`In index: ${index}, pinging: 2 `);
131+
// console.log(`In index: ${index}, pinging: 2 `);
143132
break;
144133
}
145134
case 3: {
146135
send3 = "ping";
147-
// console.log(`In index: ${index}, pinging: 3 `);
136+
// console.log(`In index: ${index}, pinging: 3 `);
148137
break;
149138
}
150139
case 4: {
151140
send4 = "ping";
152-
// console.log(`In index: ${index}, pinging: 4 `);
141+
// console.log(`In index: ${index}, pinging: 4 `);
153142
break;
154143
}
155144
case 5: {
156145
send5 = "ping";
157-
// console.log(`In index: ${index}, pinging: 5 `);
146+
// console.log(`In index: ${index}, pinging: 5 `);
158147
break;
159148
}
160149
}
161150
=}
162151

163152
reaction (receive1) -> respond1 {=
164153
respond1 = "pong";
165-
// console.log(`In index: ${index}, ponging: 1 `);
154+
// console.log(`In index: ${index}, ponging: 1 `);
166155
=}
167156

168157
reaction (receive2) -> respond2 {=
169158
respond2 = "pong";
170-
// console.log(`In index: ${index}, ponging: 2 `);
159+
// console.log(`In index: ${index}, ponging: 2 `);
171160
=}
172161

173162
reaction (receive3) -> respond3 {=
174163
respond3 = "pong";
175-
// console.log(`In index: ${index}, ponging: 3 `);
164+
// console.log(`In index: ${index}, ponging: 3 `);
176165
=}
177166

178167
reaction (receive4) -> respond4 {=
179168
respond4 = "pong";
180-
// console.log(`In index: ${index}, ponging: 4 `);
169+
// console.log(`In index: ${index}, ponging: 4 `);
181170
=}
182171

183172
reaction (receive5) -> respond5 {=
184173
respond5 = "pong";
185-
// console.log(`In index: ${index}, ponging: 5 `);
174+
// console.log(`In index: ${index}, ponging: 5 `);
186175
=}
187176

188177
reaction (start, ack1, ack2, ack3, ack4, ack5) -> nextServe, done {=
189178
remainingServes--;
190-
// console.log(`Got ack in index: ${index}, remaining serves: ${remainingServes} `);
179+
// console.log(`Got ack in index: ${index}, remaining serves: ${remainingServes} `);
191180
if (remainingServes == 0) {
181+
remainingServes = limit;
192182
done = null;
193183
} else {
194184
actions.nextServe.schedule(0, null);
@@ -203,37 +193,43 @@ reactor Sink(numberOfActors:number(5)) {
203193
input done3:null;
204194
input done4:null;
205195
input done5:null;
206-
output stopTimer:null;
196+
output stopTimer:boolean;
207197
state count:number(0);
208198

209199
reaction(done1) -> stopTimer {=
210200
count++;
211201
if (count == numberOfActors - 1) {
212-
stopTimer = null;
202+
count = 0;
203+
stopTimer = true;
213204
}
214205
=}
215206
reaction(done2) -> stopTimer {=
216207
count++;
217208
if (count == numberOfActors - 1) {
218-
stopTimer = null;
209+
count = 0;
210+
stopTimer = true;
219211
}
220212
=}
221213
reaction(done3) -> stopTimer {=
222214
count++;
223215
if (count == numberOfActors - 1) {
224-
stopTimer = null;
216+
count = 0;
217+
stopTimer = true;
225218
}
226219
=}
227220
reaction(done4) -> stopTimer {=
228221
count++;
229222
if (count == numberOfActors - 1) {
230-
stopTimer = null;
223+
count = 0;
224+
stopTimer = true;
231225
}
232226
=}
233227
reaction(done5) -> stopTimer {=
234228
count++;
235229
if (count == numberOfActors - 1) {
236-
stopTimer = null;
230+
count = 0;
231+
stopTimer = true;
237232
}
238233
=}
234+
239235
}

runner/conf/benchmark/savina_micro_big.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,12 @@ targets:
4848
run_args:
4949
messages: ["--main-num-pings-per-reactor", "<value>"]
5050
actors: ["--main-num-reactors", "<value>"]
51+
lf-ts:
52+
copy_sources:
53+
- "${bench_path}/TS/Savina/src/BenchmarkRunner.lf"
54+
- "${bench_path}/TS/Savina/src/micro"
55+
lf_file: "micro/Big.lf"
56+
script: "src-gen/micro/Big/dist/Big.js"
57+
gen_args:
58+
messages: ["-D", "numPingsPerReactor=<value>"]
59+
actors: ["-D", "numReactors=<value>"]

0 commit comments

Comments
 (0)