Skip to content

Commit 2a41745

Browse files
committed
Chameneos benchmark (add runner)
1 parent a5a40d4 commit 2a41745

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

TS/Savina/src/micro/Chameneos.lf

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ target TypeScript {
1010
fast: true
1111
};
1212

13-
main reactor Chameneos(limit:number(25000)) {
13+
import BenchmarkRunner from "../BenchmarkRunner.lf";
14+
15+
main reactor Chameneos(numIterations:number(12), limit:number(25000)) {
1416

1517
// Conversions for updateColor from https://wiki.haskell.org/Shootout/Chameneos
1618
preamble {=
17-
enum Color {RED, YELLOW, BLUE};
19+
enum Color {RED, YELLOW, BLUE}
1820
function updateColor(a : Color, b : Color) : Color {
1921
// console.log("Got a: " + a + ", b: " + b);
2022
if (a == Color.RED && b == Color.RED) return Color.RED;
@@ -29,16 +31,12 @@ main reactor Chameneos(limit:number(25000)) {
2931
return null as never;
3032
}
3133
=}
32-
state startTime:time;
33-
reaction (startup) -> m.start {=
34-
m.start = true;
35-
startTime = util.getCurrentPhysicalTime();
36-
=}
37-
reaction (m.done) {=
38-
let elapsedTime = util.getCurrentPhysicalTime().subtract(startTime as TimeValue);
39-
console.log("Elapsed time: " + elapsedTime);
40-
util.requestStop();
41-
=}
34+
35+
runner = new BenchmarkRunner(numIterations=numIterations);
36+
37+
runner.start -> m.start;
38+
m.done -> runner.finish;
39+
4240
m = new Mall(limit = limit);
4341

4442
l0 = new Lizard(initialColor = {= Color.RED =});
@@ -104,6 +102,21 @@ main reactor Chameneos(limit:number(25000)) {
104102
}
105103

106104
reactor Mall(limit:number(25000)) {
105+
106+
preamble {=
107+
function permuteLizards(freeLizards: Array<number>): Array<number> {
108+
const permutedLizards = new Array<number>();
109+
110+
while (freeLizards.length > 0) {
111+
const index = Math.floor(Math.random()*freeLizards.length);
112+
const nextLizard = freeLizards[index];
113+
freeLizards.splice(index, 1);
114+
permutedLizards.push(nextLizard);
115+
}
116+
return permutedLizards;
117+
}
118+
=}
119+
107120
input start:boolean;
108121
input ready0:boolean;
109122
input ready1:boolean;
@@ -123,19 +136,8 @@ reactor Mall(limit:number(25000)) {
123136
// Then repeat for every other available pair of lizards.
124137
reaction (ready0, ready1, ready2, ready3, ready4) -> l0instruction, l1instruction, l2instruction, l3instruction, l4instruction, done {=
125138

126-
function permuteLizards(freeLizards: Array<number>): Array<number> {
127-
let permutedLizards = new Array<number>();
128-
129-
while (freeLizards.length > 0) {
130-
let index = Math.floor(Math.random()*freeLizards.length);
131-
let nextLizard = freeLizards[index];
132-
freeLizards.splice(index, 1);
133-
permutedLizards.push(nextLizard);
134-
}
135-
return permutedLizards;
136-
}
137-
138139
if (count == limit - 1) {
140+
count = 0;
139141
done = true;
140142
} else {
141143
// Randomly permute the ready lizards, then assign pairs as friends

runner/conf/benchmark/savina_micro_chameneos.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ targets:
4545
run_args:
4646
meetings: ["--main-num-meetings", "<value>"]
4747
chameneos: ["--main-num-chameneos", "<value>"]
48+
lf-ts:
49+
copy_sources:
50+
- "${bench_path}/TS/Savina/src/BenchmarkRunner.lf"
51+
- "${bench_path}/TS/Savina/src/micro"
52+
lf_file: "micro/Chameneos.lf"
53+
script: "src-gen/micro/Chameneos/dist/Chameneos.js"
54+
gen_args:
55+
meetings: ["-D", "limit=<value>"]

0 commit comments

Comments
 (0)