-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add more benches * Rename tests * Fix hyperfine benches * Add segment arena builtin * Add RangeCheck as first argument to `run_bench` * Increase bench size
- Loading branch information
1 parent
e47a42e
commit f53c947
Showing
9 changed files
with
199 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <assert.h> | ||
#include <stdint.h> | ||
|
||
|
||
typedef struct dict_insert_return_values | ||
{ | ||
uint64_t range_check_counter; | ||
uint64_t segment_arena_counter; | ||
uint64_t remaining_gas; | ||
struct { | ||
uint8_t discriminant; | ||
struct { | ||
void *ptr; | ||
uint32_t start; | ||
uint32_t end; | ||
uint32_t cap; | ||
} err; | ||
} result; | ||
} dict_insert_return_values_t; | ||
|
||
static void run_bench(dict_insert_return_values_t *, uint64_t, uint64_t, uint64_t) | ||
__attribute__((weakref("_mlir_ciface_dict_insert::dict_insert::main(f3)"))); | ||
|
||
extern uint64_t* cairo_native__set_costs_builtin(uint64_t*); | ||
|
||
int main() | ||
{ | ||
uint64_t BuiltinCosts[7] = {1, 4050, 583, 4085, 491, 230, 604}; | ||
|
||
cairo_native__set_costs_builtin(&BuiltinCosts[0]); | ||
|
||
dict_insert_return_values_t return_values; | ||
|
||
run_bench(&return_values, 0, 0, 0xFFFFFFFFFFFFFFFF); | ||
assert((return_values.result.discriminant & 0x1) == 0); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
fn init_dict(length: u64) -> Felt252Dict<felt252> { | ||
let mut balances: Felt252Dict<felt252> = Default::default(); | ||
|
||
for i in 0..length { | ||
let x: felt252 = i.into(); | ||
balances.insert(x, x); | ||
}; | ||
|
||
return balances; | ||
} | ||
|
||
fn main() { | ||
let mut dict = init_dict(1000001); | ||
let last = dict.get(1000000); | ||
assert( | ||
last == 1000000, | ||
'invalid result' | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <assert.h> | ||
#include <stdint.h> | ||
|
||
|
||
typedef struct dict_snapshot_return_values | ||
{ | ||
uint64_t range_check_counter; | ||
uint64_t segment_arena_counter; | ||
uint64_t remaining_gas; | ||
struct { | ||
uint8_t discriminant; | ||
struct { | ||
void *ptr; | ||
uint32_t start; | ||
uint32_t end; | ||
uint32_t cap; | ||
} err; | ||
} result; | ||
} dict_snapshot_return_values_t; | ||
|
||
static void run_bench(dict_snapshot_return_values_t *, uint64_t, uint64_t, uint64_t) | ||
__attribute__((weakref("_mlir_ciface_dict_snapshot::dict_snapshot::main(f4)"))); | ||
|
||
extern uint64_t* cairo_native__set_costs_builtin(uint64_t*); | ||
|
||
int main() | ||
{ | ||
uint64_t BuiltinCosts[7] = {1, 4050, 583, 4085, 491, 230, 604}; | ||
|
||
cairo_native__set_costs_builtin(&BuiltinCosts[0]); | ||
|
||
dict_snapshot_return_values_t return_values; | ||
|
||
run_bench(&return_values, 0, 0, 0xFFFFFFFFFFFFFFFF); | ||
assert((return_values.result.discriminant & 0x1) == 0); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.