Skip to content

Commit

Permalink
tmp opt
Browse files Browse the repository at this point in the history
  • Loading branch information
StringNick committed May 7, 2024
1 parent 4217239 commit e7ac915
Show file tree
Hide file tree
Showing 14 changed files with 3,127 additions and 54 deletions.
35 changes: 35 additions & 0 deletions cairo_programs/benchmarks/compare_arrays_200000.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from starkware.cairo.common.bool import TRUE, FALSE
from starkware.cairo.common.alloc import alloc

func compare_arrays(array_a: felt*, array_b: felt*, array_length: felt, iterator: felt) -> (
r: felt
) {
if (iterator == array_length) {
return (TRUE,);
}
if (array_a[iterator] != array_b[iterator]) {
return (FALSE,);
}
return compare_arrays(array_a, array_b, array_length, iterator + 1);
}

func fill_array(array: felt*, base: felt, step: felt, array_length: felt, iterator: felt) {
if (iterator == array_length) {
return ();
}
assert array[iterator] = base + step * iterator;
return fill_array(array, base, step, array_length, iterator + 1);
}

func main() {
alloc_locals;
tempvar array_length = 250000;
let (array_a: felt*) = alloc();
let (array_b: felt*) = alloc();
fill_array(array_a, 7, 3, array_length, 0);
fill_array(array_b, 7, 3, array_length, 0);
let result: felt = compare_arrays(array_a, array_b, array_length, 0);
assert result = TRUE;
return ();
}

Loading

0 comments on commit e7ac915

Please sign in to comment.