Created
September 1, 2022 12:29
-
-
Save liamzebedee/ed0f0c90cda2be43c12202fdc75456c2 to your computer and use it in GitHub Desktop.
Benchmark Cairo pedersen hashes (hash2)
This file contains hidden or 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
| %builtins output pedersen range_check | |
| from starkware.cairo.common.cairo_builtins import HashBuiltin | |
| from starkware.cairo.common.hash import hash2 | |
| func main{ | |
| output_ptr : felt*, | |
| pedersen_ptr : HashBuiltin*, | |
| range_check_ptr, | |
| }(): | |
| benchmark_hash(0, 20000) | |
| return () | |
| end | |
| func benchmark_hash{ | |
| pedersen_ptr : HashBuiltin*, | |
| }( | |
| i : felt, | |
| n : felt | |
| ): | |
| if i == n: | |
| return () | |
| end | |
| hash2{hash_ptr=pedersen_ptr}(i, n) | |
| benchmark_hash(i + 1, n) | |
| return () | |
| end |
This file contains hidden or 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
| # Dir layout: src/ out/ scripts/build.sh | |
| cairo-compile ../src/steps.cairo --output ../out/compiled.json #--proof_mode | |
| cd .. | |
| cairo-run \ | |
| --program=./out/compiled.json \ | |
| --print_output \ | |
| --print_segments \ | |
| --print_info \ | |
| --layout all \ | |
| --memory_file ./out/memory.bin \ | |
| --trace_file ./out/trace.bin |
This file contains hidden or 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
| (.venv) (base) ➜ scripts git:(master) ✗ ./build.sh | |
| Program output: | |
| Number of steps: 160012 (originally, 160012) | |
| Used memory cells: 160051 | |
| Register values after execution: | |
| pc = 6:0 | |
| ap = 1:130015 | |
| fp = 5:0 | |
| Segment relocation table: | |
| 0 1 | |
| 1 37 | |
| 2 130052 | |
| 3 130052 | |
| 4 160052 | |
| 5 160052 | |
| 6 160052 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment