Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

birthday paradox benchmark #287

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions benchmarks/core/birthday.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ARGS: 23
@main(n: float) {
v0: float = id n;
c: float = call @probability v0;
c: float = id c;
v1: float = id c;
print v1;
v2: int = const 0;
}
@probability(n: float): float {
v0: float = const 1;
prob: float = id v0;
v2: float = const 1;
i: float = id v2;
.for.cond.1:
v3: float = id i;
v4: float = id n;
v5: bool = flt v3 v4;
br v5 .for.body.1 .for.end.1;
.for.body.1:
v6: float = const 365;
v7: float = id i;
v8: float = fsub v6 v7;
log: float = id v8;
v9: float = id log;
v10: float = const 365;
v11: float = fdiv v9 v10;
logUpdated: float = id v11;
v12: float = id prob;
v13: float = id logUpdated;
v14: float = fmul v12 v13;
prob: float = id v14;
v15: float = id i;
v16: float = const 1;
v17: float = fadd v15 v16;
i: float = id v17;
jmp .for.cond.1;
.for.end.1:
v18: float = const 1;
v19: float = id prob;
v20: float = const 100;
v21: float = fmul v19 v20;
v22: float = const 100;
v23: float = fdiv v21 v22;
v24: float = fsub v18 v23;
ret v24;
}
1 change: 1 addition & 0 deletions benchmarks/core/birthday.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.50729723432398566
1 change: 1 addition & 0 deletions benchmarks/core/birthday.prof
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
total_dyn_inst: 484
2 changes: 2 additions & 0 deletions docs/tools/bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The current benchmarks are:
* `armstrong`: Determines if the input is an [Armstrong number][armstrong], a number that is the sum of its own digits each raised to the power of the number of digits.
* `binary-fmt`: Print the binary format for the given positive integer.
* `binary-search`: Search a target integer within an integer array, outputs the index of target.
* `birthday`: Simulation of the [birthday][birthday] paradox with an input of `n` people in a given room.
* `bitwise-ops`: Computes the OR, AND, or XOR between two 64-bit integers. (Three modes: 0 = AND, 1 = OR, 2 = XOR)
* `bubblesort`: Sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
* `catalan`: Print the *n*th term in the [Catalan][catalan] sequence, compute using recursive function calls.
Expand Down Expand Up @@ -54,6 +55,7 @@ The current benchmarks are:

Credit for several of these benchmarks goes to Alexa VanHattum and Gregory Yauney, who implemented them for their [global value numbering project][gvnblog].

[birthday]: https://en.wikipedia.org/wiki/Birthday_problem
[cgroup]: https://en.wikipedia.org/wiki/Cyclic_group#Cyclically_ordered_groups
[fizzbuzz]: https://wiki.c2.com/?FizzBuzzTest
[qf]: https://en.wikipedia.org/wiki/Quadratic_formula
Expand Down