Skip to content

Commit

Permalink
fix bench (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l authored Oct 23, 2023
1 parent 15adffa commit 7dbe1af
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
34 changes: 34 additions & 0 deletions programs/benches/fib_1m.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>


typedef struct fib_return_values
{
unsigned __int128 remaining_gas;
struct {
uint8_t discriminant;
union {
uint64_t ok[4];
struct {
void *ptr;
uint32_t len;
uint32_t cap;
} err;
};
} result;
} fib_return_values_t;


static void run_bench(fib_return_values_t *, void *, uint64_t)
__attribute__((weakref("_mlir_ciface_fib_1m::fib_1m::main")));


int main()
{
fib_return_values_t return_values;

run_bench(&return_values, NULL, 0);

return return_values.result.discriminant;
}
10 changes: 10 additions & 0 deletions programs/benches/fib_1m.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn fib(a: felt252, b: felt252, n: felt252) -> felt252 {
match n {
0 => a,
_ => fib(b, a + b, n - 1),
}
}

fn main() -> felt252 {
fib(0, 1, 1000000)
}
1 change: 0 additions & 1 deletion scripts/bench-hyperfine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ run_bench() {
>> /dev/stderr

hyperfine \
--shell=none \
--warmup 3 \
--export-markdown "$OUTPUT_DIR/$base_name.md" \
"$CAIRO_RUN --available-gas 18446744073709551615 -s $base_path.cairo" \
Expand Down

0 comments on commit 7dbe1af

Please sign in to comment.