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

Add sqrt_bin_search benchmark #377

Merged
merged 1 commit into from
Jan 31, 2025
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/sqrt_bin_search.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ARGS: 37454400 0 37454400
@main(x: int, min_guess: int, max_guess: int) {
v0: int = id min_guess;
v1: int = const 1;
v2: int = add v0 v1;
min_plus_1: int = id v2;
v4: int = id min_plus_1;
v5: int = id max_guess;
v6: bool = eq v4 v5;
br v6 .then.3 .else.3;
.then.3:
v7: int = id min_guess;
print v7;
v8: int = const 0;
ret;
.else.3:
v9: int = id min_guess;
v10: int = id max_guess;
v11: int = add v9 v10;
sum_bounds: int = id v11;
v12: int = id sum_bounds;
v13: int = const 2;
v14: int = div v12 v13;
mid: int = id v14;
v15: int = id mid;
v16: int = id mid;
v17: int = mul v15 v16;
mid_squared: int = id v17;
v19: int = id mid_squared;
v20: int = id x;
v21: bool = le v19 v20;
br v21 .then.18 .else.18;
.then.18:
v22: int = id x;
v23: int = id mid;
v24: int = id max_guess;
call @main v22 v23 v24;
v25: int = const 0;
jmp .endif.18;
.else.18:
v26: int = id x;
v27: int = id min_guess;
v28: int = id mid;
call @main v26 v27 v28;
v29: int = const 0;
.endif.18:
}
1 change: 1 addition & 0 deletions benchmarks/core/sqrt_bin_search.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6120
1 change: 1 addition & 0 deletions benchmarks/core/sqrt_bin_search.prof
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
total_dyn_inst: 744
1 change: 1 addition & 0 deletions docs/tools/bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The current benchmarks are:
* `riemann`: Prints the left, midpoint, and right [Riemann][riemann] Sums for a specified function, which is the square function in this benchmark.
* `sieve`: Print all prime numbers up to *n* using the [Sieve of Eratosthenes][sievee].
* `sqrt`: Implements the [Newton–Raphson Method][newton] of approximating the square root of a number to arbitrary precision
* `sqrt_bin_search`: Uses a binary search to find the floor of the square root of an integer
* `sum-bit`: Print the number of 1-bits in the binary representation of the input integer.
* `sum-check`: Compute the sum of [1, n] by both loop and formula, and check if the result is the same.
* `sum-divisors`: Prints the positive integer divisors of the input integer, followed by the sum of the divisors.
Expand Down
Loading