From 0ccaea86f76cba119a4eb18dbfef29ffd8afd846 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 13 Oct 2020 15:35:01 +0200 Subject: [PATCH 01/13] test: introduce AST pest tests Signed-off-by: ljedrz --- ast/src/lib.rs | 2 +- ast/tests/expression.rs | 39 ++++++++++++++++++ ast/tests/function.rs | 89 +++++++++++++++++++++++++++++++++++++++++ ast/tests/mod.rs | 3 ++ ast/tests/tuple.rs | 71 ++++++++++++++++++++++++++++++++ 5 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 ast/tests/expression.rs create mode 100644 ast/tests/function.rs create mode 100644 ast/tests/tuple.rs diff --git a/ast/src/lib.rs b/ast/src/lib.rs index a81e827486..0b04d6787e 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -21,7 +21,7 @@ extern crate pest_derive; #[macro_use] extern crate thiserror; -mod ast; +pub mod ast; pub mod access; pub mod annotations; diff --git a/ast/tests/expression.rs b/ast/tests/expression.rs new file mode 100644 index 0000000000..c168d34750 --- /dev/null +++ b/ast/tests/expression.rs @@ -0,0 +1,39 @@ +use leo_ast::ast::{LanguageParser, Rule}; + +use pest::*; + +#[test] +fn redundant_parens() { + parses_to! { + parser: LanguageParser, + input: "(true)", + rule: Rule::expression, + tokens: [ + expression(0, 6, [ + expression_term(0, 6, [expression(1, 5, [expression_term(1, 5, [value(1, 5, [value_boolean(1, 5, [])])])])]) + ]) + ] + } +} + +#[test] +fn multiple_redundant_parens() { + parses_to! { + parser: LanguageParser, + input: "(((true)))", + rule: Rule::expression, + tokens: [ + expression(0, 10, [ + expression_term(0, 10, [ + expression(1, 9, [expression_term(1, 9, [ + expression(2, 8, [expression_term(2, 8, [ + expression(3, 7, [expression_term(3, 7, [ + value(3, 7, [value_boolean(3, 7, [])]) + ])]) + ])]) + ])]) + ]) + ]) + ] + } +} diff --git a/ast/tests/function.rs b/ast/tests/function.rs new file mode 100644 index 0000000000..f00037ac8d --- /dev/null +++ b/ast/tests/function.rs @@ -0,0 +1,89 @@ +use leo_ast::ast::{LanguageParser, Rule}; + +use pest::*; + +#[test] +fn call_wo_args() { + parses_to! { + parser: LanguageParser, + input: "x()", + rule: Rule::expression_postfix, + tokens: [ + expression_postfix(0, 3, [ + keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]), + access(1, 3, [access_call(1, 3, [expression_tuple(1, 3, [])])]) + ]) + ] + } +} + +#[test] +fn call_with_arg() { + parses_to! { + parser: LanguageParser, + input: "x(true)", + rule: Rule::expression_postfix, + tokens: [ + expression_postfix(0, 7, [ + keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]), + access(1, 7, [access_call(1, 7, [expression_tuple(1, 7, [ + expression(2, 6, [expression_term(2, 6, [value(2, 6, [value_boolean(2, 6, [])])])]) + ])])]) + ]) + ] + } +} + +#[test] +fn call_with_2_args() { + parses_to! { + parser: LanguageParser, + input: "x(true, false)", + rule: Rule::expression_postfix, + tokens: [ + expression_postfix(0, 14, [ + keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]), + access(1, 14, [access_call(1, 14, [expression_tuple(1, 14, [ + expression(2, 6, [expression_term(2, 6, [value(2, 6, [value_boolean(2, 6, [])])])]), + expression(8, 13, [expression_term(8, 13, [value(8, 13, [value_boolean(8, 13, [])])])]) + ])])]) + ]) + ] + } +} + +#[test] +fn empty_def() { + parses_to! { + parser: LanguageParser, + input: "function x() {}", + rule: Rule::function, + tokens: [ + function(0, 15, [identifier(9, 10, [])]) + ] + } +} + +#[test] +fn id_def() { + parses_to! { + parser: LanguageParser, + input: "function id(x: u8) -> u8 { return x }", + rule: Rule::function, + tokens: [ + function(0, 37, [ + identifier(9, 11, []), + input(12, 17, [ + function_input(12, 17, [ + identifier(12, 13, []), + type_(15, 17, [type_data(15, 17, [type_integer(15, 17, [type_integer_unsigned(15, 17, [type_u8(15, 17, [])])])])]) + ]) + ]), + type_(22, 24, [type_data(22, 24, [type_integer(22, 24, [type_integer_unsigned(22, 24, [type_u8(22, 24, [])])])])]), + statement(27, 36, [statement_return(27, 36, [ + expression(34, 36, [expression_term(34, 35, [identifier(34, 35, [])])]) + ])]) + ]) + ] + } +} diff --git a/ast/tests/mod.rs b/ast/tests/mod.rs index 6698b5585a..b4ed4e6d07 100644 --- a/ast/tests/mod.rs +++ b/ast/tests/mod.rs @@ -14,4 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . +mod expression; +mod function; mod serialization; +mod tuple; diff --git a/ast/tests/tuple.rs b/ast/tests/tuple.rs new file mode 100644 index 0000000000..284e1603cb --- /dev/null +++ b/ast/tests/tuple.rs @@ -0,0 +1,71 @@ +use leo_ast::ast::{LanguageParser, Rule}; + +use pest::*; + +#[test] +fn implicitly_typed() { + parses_to! { + parser: LanguageParser, + input: "(true, false)", + rule: Rule::expression_tuple, + tokens: [ + expression_tuple(0, 13, [ + expression(1, 5, [expression_term(1, 5, [value(1, 5, [value_boolean(1, 5, [])])])]), + expression(7, 12, [expression_term(7, 12, [value(7, 12, [value_boolean(7, 12, [])])])]) + ]) + ] + } +} + +#[test] +fn explicitly_typed() { + parses_to! { + parser: LanguageParser, + input: "let tup: (bool, bool) = (true, false);", + rule: Rule::statement_definition, + tokens: [ + statement_definition(0, 38, [ + declare(0, 4, [let_(0, 4, [])]), + variables(4, 21, [ + variable_name(4, 7, [identifier(4, 7, [])]), + type_(9, 21, [type_tuple(9, 21, [ + type_(10, 14, [type_data(10, 14, [type_boolean(10, 14, [])])]), + type_(16, 20, [type_data(16, 20, [type_boolean(16, 20, [])])]), + ])]) + ]), + expression(24, 37, [expression_term(24, 37, [expression_tuple(24, 37, [ + expression(25, 29, [expression_term(25, 29, [value(25, 29, [value_boolean(25, 29, [])])])]), + expression(31, 36, [expression_term(31, 36, [value(31, 36, [value_boolean(31, 36, [])])])]), + ])])]), + LINE_END(37, 38, []) + ]) + ] + } +} + +#[test] +fn access() { + parses_to! { + parser: LanguageParser, + input: "x.0", + rule: Rule::expression_postfix, + tokens: [ + expression_postfix(0, 3, [ + keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]), + access(1, 3, [access_tuple(1, 3, [number_positive(2, 3, [])])]) + ]) + ] + } +} + +#[test] +fn unit() { + parses_to! { + parser: LanguageParser, + input: "()", + rule: Rule::expression_tuple, + tokens: [ + expression_tuple(0, 2, []) + ] + } +} From 88cdbd4fe6d0199c78e40c133fe3f2d27d24880f Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 14 Oct 2020 10:50:26 +0200 Subject: [PATCH 02/13] refactor(ast): remove the expression_tuple indirection from access_call Signed-off-by: ljedrz --- ast/src/access/call_access.rs | 4 ++-- ast/src/leo.pest | 2 +- ast/tests/function.rs | 12 ++++++------ typed/src/expression.rs | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ast/src/access/call_access.rs b/ast/src/access/call_access.rs index 0b26c5c6f3..00bd0e19d6 100644 --- a/ast/src/access/call_access.rs +++ b/ast/src/access/call_access.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::{ast::Rule, expressions::TupleExpression, SpanDef}; +use crate::{ast::Rule, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; @@ -23,7 +23,7 @@ use serde::Serialize; #[derive(Clone, Debug, FromPest, PartialEq, Serialize)] #[pest_ast(rule(Rule::access_call))] pub struct CallAccess<'ast> { - pub expressions: TupleExpression<'ast>, + pub expressions: Vec>, #[pest_ast(outer())] #[serde(with = "SpanDef")] pub span: Span<'ast>, diff --git a/ast/src/leo.pest b/ast/src/leo.pest index 69a002f37d..c3d9fc7fd8 100644 --- a/ast/src/leo.pest +++ b/ast/src/leo.pest @@ -302,7 +302,7 @@ access_tuple = ${ "." ~ number_positive } access_assignee = { access_array | access_tuple | access_member } // Declared in access/call_access.rs -access_call = !{ expression_tuple } +access_call = !{ "(" ~ (expression ~ ("," ~ expression)*)? ~ ")" } // Declared in access/member_access.rs access_member = ${ "." ~ identifier } diff --git a/ast/tests/function.rs b/ast/tests/function.rs index f00037ac8d..c5273da720 100644 --- a/ast/tests/function.rs +++ b/ast/tests/function.rs @@ -11,7 +11,7 @@ fn call_wo_args() { tokens: [ expression_postfix(0, 3, [ keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]), - access(1, 3, [access_call(1, 3, [expression_tuple(1, 3, [])])]) + access(1, 3, [access_call(1, 3, [])]) ]) ] } @@ -26,9 +26,9 @@ fn call_with_arg() { tokens: [ expression_postfix(0, 7, [ keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]), - access(1, 7, [access_call(1, 7, [expression_tuple(1, 7, [ - expression(2, 6, [expression_term(2, 6, [value(2, 6, [value_boolean(2, 6, [])])])]) - ])])]) + access(1, 7, [access_call(1, 7, [ + expression(2, 6, [expression_term(2, 6, [value(2, 6, [value_boolean(2, 6, [])])])]) + ])]) ]) ] } @@ -43,10 +43,10 @@ fn call_with_2_args() { tokens: [ expression_postfix(0, 14, [ keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]), - access(1, 14, [access_call(1, 14, [expression_tuple(1, 14, [ + access(1, 14, [access_call(1, 14, [ expression(2, 6, [expression_term(2, 6, [value(2, 6, [value_boolean(2, 6, [])])])]), expression(8, 13, [expression_term(8, 13, [value(8, 13, [value_boolean(8, 13, [])])])]) - ])])]) + ])]) ]) ] } diff --git a/typed/src/expression.rs b/typed/src/expression.rs index 5fc2543c1a..6c4e33e807 100644 --- a/typed/src/expression.rs +++ b/typed/src/expression.rs @@ -340,7 +340,6 @@ impl<'ast> From> for Expression { Expression::FunctionCall( Box::new(acc), function - .expressions .expressions .into_iter() .map(|expression| Expression::from(expression)) From e2f084877356dfdbf3388dd0bf8c163c3074cbff Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 14 Oct 2020 11:01:51 +0200 Subject: [PATCH 03/13] fix(ast): disallow single-member tuples Signed-off-by: ljedrz --- ast/src/leo.pest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ast/src/leo.pest b/ast/src/leo.pest index c3d9fc7fd8..f9b6c9f4cb 100644 --- a/ast/src/leo.pest +++ b/ast/src/leo.pest @@ -351,7 +351,7 @@ expression_term = { expression = { expression_term ~ (operation_binary ~ expression_term)* } // Declared in expressions/expression_tuple.rs -expression_tuple = { "(" ~ (expression ~ ("," ~ expression)*)? ~ ")" } +expression_tuple = { "(" ~ (expression ~ ("," ~ expression)+)? ~ ")" } // Declared in expressions/array_initializer_expression.rs expression_array_initializer = { "[" ~ expression ~ ";" ~ array_dimensions ~ "]" } From d1ee66a7475803c4b2daf04b9b047471ed028a94 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 14 Oct 2020 12:22:31 +0200 Subject: [PATCH 04/13] feat(ast): handle the empty tuple type Signed-off-by: ljedrz --- ast/src/leo.pest | 2 +- ast/tests/tuple.rs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ast/src/leo.pest b/ast/src/leo.pest index f9b6c9f4cb..71024b6439 100644 --- a/ast/src/leo.pest +++ b/ast/src/leo.pest @@ -226,7 +226,7 @@ dimension_single = { // Declared in types/array_dimensions.rs dimension_multiple = { "(" ~ number_positive ~ ("," ~ number_positive)* ~ ")"} -type_tuple = { "(" ~ NEWLINE* ~ type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","? ~ NEWLINE* ~ ")" } +type_tuple = { "(" ~ NEWLINE* ~ (type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","?)? ~ NEWLINE* ~ ")" } /// Values diff --git a/ast/tests/tuple.rs b/ast/tests/tuple.rs index 284e1603cb..4b550214fe 100644 --- a/ast/tests/tuple.rs +++ b/ast/tests/tuple.rs @@ -59,7 +59,7 @@ fn access() { } #[test] -fn unit() { +fn implicit_unit() { parses_to! { parser: LanguageParser, input: "()", @@ -69,3 +69,23 @@ fn unit() { ] } } + +#[test] +fn explicit_unit() { + parses_to! { + parser: LanguageParser, + input: "let x: () = ();", + rule: Rule::statement_definition, + tokens: [ + statement_definition(0, 15, [ + declare(0, 4, [let_(0, 4, [])]), + variables(4, 9, [ + variable_name(4, 5, [identifier(4, 5, [])]), + type_(7, 9, [type_tuple(7, 9, [])]) + ]), + expression(12, 14, [expression_term(12, 14, [expression_tuple(12, 14, [])])]), + LINE_END(14, 15, []) + ]) + ] + } +} From 88bd491684f78ad5d7211c6fa6517caa0ad8a080 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 14 Oct 2020 12:35:04 +0200 Subject: [PATCH 05/13] test: add extra AST pest tests Signed-off-by: ljedrz --- ast/tests/function.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ast/tests/function.rs b/ast/tests/function.rs index c5273da720..f35ed1f47e 100644 --- a/ast/tests/function.rs +++ b/ast/tests/function.rs @@ -64,6 +64,32 @@ fn empty_def() { } } +#[test] +fn returning_unit_type() { + parses_to! { + parser: LanguageParser, + input: "function x() -> () {}", + rule: Rule::function, + tokens: [ + function(0, 21, [identifier(9, 10, []), type_(16, 18, [type_tuple(16, 18, [])])]) + ] + } +} + +#[test] +fn returning_unit_value() { + parses_to! { + parser: LanguageParser, + input: "function x() { return () }", + rule: Rule::function, + tokens: [ + function(0, 26, [identifier(9, 10, []), statement(15, 25, [ + statement_return(15, 25, [expression(22, 25, [expression_term(22, 24, [expression_tuple(22, 24, [])])])]) + ])]) + ] + } +} + #[test] fn id_def() { parses_to! { From 07743b2d7577e8d5eaab15ea83e8c0ad7e442418 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 14 Oct 2020 13:08:13 +0200 Subject: [PATCH 06/13] bench: change the AST bench to a much more complex one Signed-off-by: ljedrz --- ast/benches/ast.rs | 14 +++++--------- ast/benches/main.leo | 27 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/ast/benches/ast.rs b/ast/benches/ast.rs index 5d4cc3f436..4d0eb690ec 100644 --- a/ast/benches/ast.rs +++ b/ast/benches/ast.rs @@ -14,24 +14,20 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::{errors::ParserError, files::File, LeoAst}; +use leo_ast::LeoAst; -use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use criterion::{criterion_group, criterion_main, Criterion}; use std::path::{Path, PathBuf}; -fn leo_ast<'ast>(filepath: &'ast PathBuf, program_string: &'ast str) { - let result = LeoAst::<'ast>::new(filepath, program_string).unwrap(); - black_box(result); +fn leo_ast<'ast>(filepath: &'ast PathBuf, program_string: &'ast str) -> LeoAst<'ast> { + LeoAst::<'ast>::new(filepath, program_string).unwrap() } fn criterion_benchmark(c: &mut Criterion) { let filepath = Path::new("./main.leo").to_path_buf(); - // let program_string = &LeoAst::load_file(&filepath).unwrap(); let program_string = include_str!("./main.leo"); - c.bench_function("LeoAst::new", |b| { - b.iter(|| leo_ast(black_box(&filepath), black_box(program_string))) - }); + c.bench_function("LeoAst::new", |b| b.iter(|| leo_ast(&filepath, program_string))); } criterion_group!(benches, criterion_benchmark); diff --git a/ast/benches/main.leo b/ast/benches/main.leo index ef22115243..6b094d9aae 100644 --- a/ast/benches/main.leo +++ b/ast/benches/main.leo @@ -1,3 +1,26 @@ -function main() { - return 1 + 1 +circuit PedersenHash { + parameters: [group; 256], + + // Instantiates a Pedersen hash circuit + static function new(parameters: [group; 256]) -> Self { + return Self { parameters: parameters } + } + + function hash(bits: [bool; 256]) -> group { + let mut digest: group = 0; + for i in 0..256 { + if bits[i] { + digest += self.parameters[i]; + } + } + return digest + } +} + +// The 'pedersen-hash' main function. +function main() -> group { + const parameters = [1group; 256]; + const pedersen = PedersenHash::new(parameters); + let hash_input: [bool; 256] = [true; 256]; + return pedersen.hash(hash_input) } From 845671547f77eb81c3e668ba14f857f94cb4c840 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 14 Oct 2020 13:24:59 +0200 Subject: [PATCH 07/13] perf: don't clone the whole iterator while parsing expressions Signed-off-by: ljedrz --- ast/src/ast.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ast/src/ast.rs b/ast/src/ast.rs index 7906332c4d..19af9745f7 100644 --- a/ast/src/ast.rs +++ b/ast/src/ast.rs @@ -163,12 +163,11 @@ impl<'ast> FromPest<'ast> for Expression<'ast> { type Rule = Rule; fn from_pest(pest: &mut Pairs<'ast, Rule>) -> Result> { - let mut clone = pest.clone(); - let pair = clone.next().ok_or(::from_pest::ConversionError::NoMatch)?; + let pair = pest.peek().ok_or(::from_pest::ConversionError::NoMatch)?; match pair.as_rule() { Rule::expression => { - // Transfer iterated state to pest. - *pest = clone; + // advance the iterator + pest.next(); Ok(*PRECEDENCE_CLIMBER.climb(pair.into_inner(), parse_term, binary_expression)) } _ => Err(ConversionError::NoMatch), From 39cd98d2c0eb409e62fda97edc0237d6c3705ac6 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 7 Oct 2020 13:38:11 +0200 Subject: [PATCH 08/13] bench: extend the LeoTypedAst benchmarks Signed-off-by: ljedrz --- typed/benches/big_circuit.leo | 265 ++++++++++++++++++++++ typed/benches/big_if_else.leo | 389 +++++++++++++++++++++++++++++++++ typed/benches/big_ternary.leo | 5 + typed/benches/long_array.leo | 57 +++++ typed/benches/long_expr.leo | 9 + typed/benches/main.leo | 3 - typed/benches/many_assigns.leo | 388 ++++++++++++++++++++++++++++++++ typed/benches/many_foos.leo | 196 +++++++++++++++++ typed/benches/typed_ast.rs | 81 ++++++- 9 files changed, 1379 insertions(+), 14 deletions(-) create mode 100644 typed/benches/big_circuit.leo create mode 100644 typed/benches/big_if_else.leo create mode 100644 typed/benches/big_ternary.leo create mode 100644 typed/benches/long_array.leo create mode 100644 typed/benches/long_expr.leo delete mode 100644 typed/benches/main.leo create mode 100644 typed/benches/many_assigns.leo create mode 100644 typed/benches/many_foos.leo diff --git a/typed/benches/big_circuit.leo b/typed/benches/big_circuit.leo new file mode 100644 index 0000000000..32011551c0 --- /dev/null +++ b/typed/benches/big_circuit.leo @@ -0,0 +1,265 @@ +function main() { + let foo = Foo { x0: 0, x1: 1, x2: 2, x3: 3, x4: 4, x5: 5, x6: 6, x7: 7, x8: 8, x9: 9, x10: 10, x11: 11, x12: 12, x13: 13, x14: 14, x15: 15, x16: 16, x17: 17, x18: 18, x19: 19, x20: 20, x21: 21, x22: 22, x23: 23, x24: 24, x25: 25, x26: 26, x27: 27, x28: 28, x29: 29, x30: 30, x31: 31, x32: 32, x33: 33, x34: 34, x35: 35, x36: 36, x37: 37, x38: 38, x39: 39, x40: 40, x41: 41, x42: 42, x43: 43, x44: 44, x45: 45, x46: 46, x47: 47, x48: 48, x49: 49, x50: 50, x51: 51, x52: 52, x53: 53, x54: 54, x55: 55, x56: 56, x57: 57, x58: 58, x59: 59, x60: 60, x61: 61, x62: 62, x63: 63, x64: 64, x65: 65, x66: 66, x67: 67, x68: 68, x69: 69, x70: 70, x71: 71, x72: 72, x73: 73, x74: 74, x75: 75, x76: 76, x77: 77, x78: 78, x79: 79, x80: 80, x81: 81, x82: 82, x83: 83, x84: 84, x85: 85, x86: 86, x87: 87, x88: 88, x89: 89, x90: 90, x91: 91, x92: 92, x93: 93, x94: 94, x95: 95, x96: 96, x97: 97, x98: 98, x99: 99, x100: 100, x101: 101, x102: 102, x103: 103, x104: 104, x105: 105, x106: 106, x107: 107, x108: 108, x109: 109, x110: 110, x111: 111, x112: 112, x113: 113, x114: 114, x115: 115, x116: 116, x117: 117, x118: 118, x119: 119, x120: 120, x121: 121, x122: 122, x123: 123, x124: 124, x125: 125, x126: 126, x127: 127, x128: 128, x129: 129, x130: 130, x131: 131, x132: 132, x133: 133, x134: 134, x135: 135, x136: 136, x137: 137, x138: 138, x139: 139, x140: 140, x141: 141, x142: 142, x143: 143, x144: 144, x145: 145, x146: 146, x147: 147, x148: 148, x149: 149, x150: 150, x151: 151, x152: 152, x153: 153, x154: 154, x155: 155, x156: 156, x157: 157, x158: 158, x159: 159, x160: 160, x161: 161, x162: 162, x163: 163, x164: 164, x165: 165, x166: 166, x167: 167, x168: 168, x169: 169, x170: 170, x171: 171, x172: 172, x173: 173, x174: 174, x175: 175, x176: 176, x177: 177, x178: 178, x179: 179, x180: 180, x181: 181, x182: 182, x183: 183, x184: 184, x185: 185, x186: 186, x187: 187, x188: 188, x189: 189, x190: 190, x191: 191, x192: 192, x193: 193, x194: 194, x195: 195, x196: 196, x197: 197, x198: 198, x199: 199, x200: 200, x201: 201, x202: 202, x203: 203, x204: 204, x205: 205, x206: 206, x207: 207, x208: 208, x209: 209, x210: 210, x211: 211, x212: 212, x213: 213, x214: 214, x215: 215, x216: 216, x217: 217, x218: 218, x219: 219, x220: 220, x221: 221, x222: 222, x223: 223, x224: 224, x225: 225, x226: 226, x227: 227, x228: 228, x229: 229, x230: 230, x231: 231, x232: 232, x233: 233, x234: 234, x235: 235, x236: 236, x237: 237, x238: 238, x239: 239, x240: 240, x241: 241, x242: 242, x243: 243, x244: 244, x245: 245, x246: 246, x247: 247, x248: 248, x249: 249, x250: 250, x251: 251, x252: 252, x253: 253, x254: 254, x255: 255 }; + let bar = Foo { x0: 0, x1: 1, x2: 2, x3: 3, x4: 4, x5: 5, x6: 6, x7: 7, x8: 8, x9: 9, x10: 10, x11: 11, x12: 12, x13: 13, x14: 14, x15: 15, x16: 16, x17: 17, x18: 18, x19: 19, x20: 20, x21: 21, x22: 22, x23: 23, x24: 24, x25: 25, x26: 26, x27: 27, x28: 28, x29: 29, x30: 30, x31: 31, x32: 32, x33: 33, x34: 34, x35: 35, x36: 36, x37: 37, x38: 38, x39: 39, x40: 40, x41: 41, x42: 42, x43: 43, x44: 44, x45: 45, x46: 46, x47: 47, x48: 48, x49: 49, x50: 50, x51: 51, x52: 52, x53: 53, x54: 54, x55: 55, x56: 56, x57: 57, x58: 58, x59: 59, x60: 60, x61: 61, x62: 62, x63: 63, x64: 64, x65: 65, x66: 66, x67: 67, x68: 68, x69: 69, x70: 70, x71: 71, x72: 72, x73: 73, x74: 74, x75: 75, x76: 76, x77: 77, x78: 78, x79: 79, x80: 80, x81: 81, x82: 82, x83: 83, x84: 84, x85: 85, x86: 86, x87: 87, x88: 88, x89: 89, x90: 90, x91: 91, x92: 92, x93: 93, x94: 94, x95: 95, x96: 96, x97: 97, x98: 98, x99: 99, x100: 100, x101: 101, x102: 102, x103: 103, x104: 104, x105: 105, x106: 106, x107: 107, x108: 108, x109: 109, x110: 110, x111: 111, x112: 112, x113: 113, x114: 114, x115: 115, x116: 116, x117: 117, x118: 118, x119: 119, x120: 120, x121: 121, x122: 122, x123: 123, x124: 124, x125: 125, x126: 126, x127: 127, x128: 128, x129: 129, x130: 130, x131: 131, x132: 132, x133: 133, x134: 134, x135: 135, x136: 136, x137: 137, x138: 138, x139: 139, x140: 140, x141: 141, x142: 142, x143: 143, x144: 144, x145: 145, x146: 146, x147: 147, x148: 148, x149: 149, x150: 150, x151: 151, x152: 152, x153: 153, x154: 154, x155: 155, x156: 156, x157: 157, x158: 158, x159: 159, x160: 160, x161: 161, x162: 162, x163: 163, x164: 164, x165: 165, x166: 166, x167: 167, x168: 168, x169: 169, x170: 170, x171: 171, x172: 172, x173: 173, x174: 174, x175: 175, x176: 176, x177: 177, x178: 178, x179: 179, x180: 180, x181: 181, x182: 182, x183: 183, x184: 184, x185: 185, x186: 186, x187: 187, x188: 188, x189: 189, x190: 190, x191: 191, x192: 192, x193: 193, x194: 194, x195: 195, x196: 196, x197: 197, x198: 198, x199: 199, x200: 200, x201: 201, x202: 202, x203: 203, x204: 204, x205: 205, x206: 206, x207: 207, x208: 208, x209: 209, x210: 210, x211: 211, x212: 212, x213: 213, x214: 214, x215: 215, x216: 216, x217: 217, x218: 218, x219: 219, x220: 220, x221: 221, x222: 222, x223: 223, x224: 224, x225: 225, x226: 226, x227: 227, x228: 228, x229: 229, x230: 230, x231: 231, x232: 232, x233: 233, x234: 234, x235: 235, x236: 236, x237: 237, x238: 238, x239: 239, x240: 240, x241: 241, x242: 242, x243: 243, x244: 244, x245: 245, x246: 246, x247: 247, x248: 248, x249: 249, x250: 250, x251: 251, x252: 252, x253: 253, x254: 254, x255: 255 }; + + return foo.x0 + bar.x255 +} + +circuit Foo { + x0: u8, + x1: u8, + x2: u8, + x3: u8, + x4: u8, + x5: u8, + x6: u8, + x7: u8, + x8: u8, + x9: u8, + x10: u8, + x11: u8, + x12: u8, + x13: u8, + x14: u8, + x15: u8, + x16: u8, + x17: u8, + x18: u8, + x19: u8, + x20: u8, + x21: u8, + x22: u8, + x23: u8, + x24: u8, + x25: u8, + x26: u8, + x27: u8, + x28: u8, + x29: u8, + x30: u8, + x31: u8, + x32: u8, + x33: u8, + x34: u8, + x35: u8, + x36: u8, + x37: u8, + x38: u8, + x39: u8, + x40: u8, + x41: u8, + x42: u8, + x43: u8, + x44: u8, + x45: u8, + x46: u8, + x47: u8, + x48: u8, + x49: u8, + x50: u8, + x51: u8, + x52: u8, + x53: u8, + x54: u8, + x55: u8, + x56: u8, + x57: u8, + x58: u8, + x59: u8, + x60: u8, + x61: u8, + x62: u8, + x63: u8, + x64: u8, + x65: u8, + x66: u8, + x67: u8, + x68: u8, + x69: u8, + x70: u8, + x71: u8, + x72: u8, + x73: u8, + x74: u8, + x75: u8, + x76: u8, + x77: u8, + x78: u8, + x79: u8, + x80: u8, + x81: u8, + x82: u8, + x83: u8, + x84: u8, + x85: u8, + x86: u8, + x87: u8, + x88: u8, + x89: u8, + x90: u8, + x91: u8, + x92: u8, + x93: u8, + x94: u8, + x95: u8, + x96: u8, + x97: u8, + x98: u8, + x99: u8, + x100: u8, + x101: u8, + x102: u8, + x103: u8, + x104: u8, + x105: u8, + x106: u8, + x107: u8, + x108: u8, + x109: u8, + x110: u8, + x111: u8, + x112: u8, + x113: u8, + x114: u8, + x115: u8, + x116: u8, + x117: u8, + x118: u8, + x119: u8, + x120: u8, + x121: u8, + x122: u8, + x123: u8, + x124: u8, + x125: u8, + x126: u8, + x127: u8, + x128: u8, + x129: u8, + x130: u8, + x131: u8, + x132: u8, + x133: u8, + x134: u8, + x135: u8, + x136: u8, + x137: u8, + x138: u8, + x139: u8, + x140: u8, + x141: u8, + x142: u8, + x143: u8, + x144: u8, + x145: u8, + x146: u8, + x147: u8, + x148: u8, + x149: u8, + x150: u8, + x151: u8, + x152: u8, + x153: u8, + x154: u8, + x155: u8, + x156: u8, + x157: u8, + x158: u8, + x159: u8, + x160: u8, + x161: u8, + x162: u8, + x163: u8, + x164: u8, + x165: u8, + x166: u8, + x167: u8, + x168: u8, + x169: u8, + x170: u8, + x171: u8, + x172: u8, + x173: u8, + x174: u8, + x175: u8, + x176: u8, + x177: u8, + x178: u8, + x179: u8, + x180: u8, + x181: u8, + x182: u8, + x183: u8, + x184: u8, + x185: u8, + x186: u8, + x187: u8, + x188: u8, + x189: u8, + x190: u8, + x191: u8, + x192: u8, + x193: u8, + x194: u8, + x195: u8, + x196: u8, + x197: u8, + x198: u8, + x199: u8, + x200: u8, + x201: u8, + x202: u8, + x203: u8, + x204: u8, + x205: u8, + x206: u8, + x207: u8, + x208: u8, + x209: u8, + x210: u8, + x211: u8, + x212: u8, + x213: u8, + x214: u8, + x215: u8, + x216: u8, + x217: u8, + x218: u8, + x219: u8, + x220: u8, + x221: u8, + x222: u8, + x223: u8, + x224: u8, + x225: u8, + x226: u8, + x227: u8, + x228: u8, + x229: u8, + x230: u8, + x231: u8, + x232: u8, + x233: u8, + x234: u8, + x235: u8, + x236: u8, + x237: u8, + x238: u8, + x239: u8, + x240: u8, + x241: u8, + x242: u8, + x243: u8, + x244: u8, + x245: u8, + x246: u8, + x247: u8, + x248: u8, + x249: u8, + x250: u8, + x251: u8, + x252: u8, + x253: u8, + x254: u8, + x255: u8 +} \ No newline at end of file diff --git a/typed/benches/big_if_else.leo b/typed/benches/big_if_else.leo new file mode 100644 index 0000000000..6c974f12a3 --- /dev/null +++ b/typed/benches/big_if_else.leo @@ -0,0 +1,389 @@ +function main() { + let x: u8 = 191; + + if x == 0 { + return x + } else if x == 1 { + return x - 1 + } else if x == 2 { + return x - 2 + } else if x == 3 { + return x - 3 + } else if x == 4 { + return x - 4 + } else if x == 5 { + return x - 5 + } else if x == 6 { + return x - 6 + } else if x == 7 { + return x - 7 + } else if x == 8 { + return x - 8 + } else if x == 9 { + return x - 9 + } else if x == 10 { + return x - 10 + } else if x == 11 { + return x - 11 + } else if x == 12 { + return x - 12 + } else if x == 13 { + return x - 13 + } else if x == 14 { + return x - 14 + } else if x == 15 { + return x - 15 + } else if x == 16 { + return x - 16 + } else if x == 17 { + return x - 17 + } else if x == 18 { + return x - 18 + } else if x == 19 { + return x - 19 + } else if x == 20 { + return x - 20 + } else if x == 21 { + return x - 21 + } else if x == 22 { + return x - 22 + } else if x == 23 { + return x - 23 + } else if x == 24 { + return x - 24 + } else if x == 25 { + return x - 25 + } else if x == 26 { + return x - 26 + } else if x == 27 { + return x - 27 + } else if x == 28 { + return x - 28 + } else if x == 29 { + return x - 29 + } else if x == 30 { + return x - 30 + } else if x == 31 { + return x - 31 + } else if x == 32 { + return x - 32 + } else if x == 33 { + return x - 33 + } else if x == 34 { + return x - 34 + } else if x == 35 { + return x - 35 + } else if x == 36 { + return x - 36 + } else if x == 37 { + return x - 37 + } else if x == 38 { + return x - 38 + } else if x == 39 { + return x - 39 + } else if x == 40 { + return x - 40 + } else if x == 41 { + return x - 41 + } else if x == 42 { + return x - 42 + } else if x == 43 { + return x - 43 + } else if x == 44 { + return x - 44 + } else if x == 45 { + return x - 45 + } else if x == 46 { + return x - 46 + } else if x == 47 { + return x - 47 + } else if x == 48 { + return x - 48 + } else if x == 49 { + return x - 49 + } else if x == 50 { + return x - 50 + } else if x == 51 { + return x - 51 + } else if x == 52 { + return x - 52 + } else if x == 53 { + return x - 53 + } else if x == 54 { + return x - 54 + } else if x == 55 { + return x - 55 + } else if x == 56 { + return x - 56 + } else if x == 57 { + return x - 57 + } else if x == 58 { + return x - 58 + } else if x == 59 { + return x - 59 + } else if x == 60 { + return x - 60 + } else if x == 61 { + return x - 61 + } else if x == 62 { + return x - 62 + } else if x == 63 { + return x - 63 + } else if x == 64 { + return x - 64 + } else if x == 65 { + return x - 65 + } else if x == 66 { + return x - 66 + } else if x == 67 { + return x - 67 + } else if x == 68 { + return x - 68 + } else if x == 69 { + return x - 69 + } else if x == 70 { + return x - 70 + } else if x == 71 { + return x - 71 + } else if x == 72 { + return x - 72 + } else if x == 73 { + return x - 73 + } else if x == 74 { + return x - 74 + } else if x == 75 { + return x - 75 + } else if x == 76 { + return x - 76 + } else if x == 77 { + return x - 77 + } else if x == 78 { + return x - 78 + } else if x == 79 { + return x - 79 + } else if x == 80 { + return x - 80 + } else if x == 81 { + return x - 81 + } else if x == 82 { + return x - 82 + } else if x == 83 { + return x - 83 + } else if x == 84 { + return x - 84 + } else if x == 85 { + return x - 85 + } else if x == 86 { + return x - 86 + } else if x == 87 { + return x - 87 + } else if x == 88 { + return x - 88 + } else if x == 89 { + return x - 89 + } else if x == 90 { + return x - 90 + } else if x == 91 { + return x - 91 + } else if x == 92 { + return x - 92 + } else if x == 93 { + return x - 93 + } else if x == 94 { + return x - 94 + } else if x == 95 { + return x - 95 + } else if x == 96 { + return x - 96 + } else if x == 97 { + return x - 97 + } else if x == 98 { + return x - 98 + } else if x == 99 { + return x - 99 + } else if x == 100 { + return x - 100 + } else if x == 101 { + return x - 101 + } else if x == 102 { + return x - 102 + } else if x == 103 { + return x - 103 + } else if x == 104 { + return x - 104 + } else if x == 105 { + return x - 105 + } else if x == 106 { + return x - 106 + } else if x == 107 { + return x - 107 + } else if x == 108 { + return x - 108 + } else if x == 109 { + return x - 109 + } else if x == 110 { + return x - 110 + } else if x == 111 { + return x - 111 + } else if x == 112 { + return x - 112 + } else if x == 113 { + return x - 113 + } else if x == 114 { + return x - 114 + } else if x == 115 { + return x - 115 + } else if x == 116 { + return x - 116 + } else if x == 117 { + return x - 117 + } else if x == 118 { + return x - 118 + } else if x == 119 { + return x - 119 + } else if x == 120 { + return x - 120 + } else if x == 121 { + return x - 121 + } else if x == 122 { + return x - 122 + } else if x == 123 { + return x - 123 + } else if x == 124 { + return x - 124 + } else if x == 125 { + return x - 125 + } else if x == 126 { + return x - 126 + } else if x == 127 { + return x - 127 + } else if x == 128 { + return x - 128 + } else if x == 129 { + return x - 129 + } else if x == 130 { + return x - 130 + } else if x == 131 { + return x - 131 + } else if x == 132 { + return x - 132 + } else if x == 133 { + return x - 133 + } else if x == 134 { + return x - 134 + } else if x == 135 { + return x - 135 + } else if x == 136 { + return x - 136 + } else if x == 137 { + return x - 137 + } else if x == 138 { + return x - 138 + } else if x == 139 { + return x - 139 + } else if x == 140 { + return x - 140 + } else if x == 141 { + return x - 141 + } else if x == 142 { + return x - 142 + } else if x == 143 { + return x - 143 + } else if x == 144 { + return x - 144 + } else if x == 145 { + return x - 145 + } else if x == 146 { + return x - 146 + } else if x == 147 { + return x - 147 + } else if x == 148 { + return x - 148 + } else if x == 149 { + return x - 149 + } else if x == 150 { + return x - 150 + } else if x == 151 { + return x - 151 + } else if x == 152 { + return x - 152 + } else if x == 153 { + return x - 153 + } else if x == 154 { + return x - 154 + } else if x == 155 { + return x - 155 + } else if x == 156 { + return x - 156 + } else if x == 157 { + return x - 157 + } else if x == 158 { + return x - 158 + } else if x == 159 { + return x - 159 + } else if x == 160 { + return x - 160 + } else if x == 161 { + return x - 161 + } else if x == 162 { + return x - 162 + } else if x == 163 { + return x - 163 + } else if x == 164 { + return x - 164 + } else if x == 165 { + return x - 165 + } else if x == 166 { + return x - 166 + } else if x == 167 { + return x - 167 + } else if x == 168 { + return x - 168 + } else if x == 169 { + return x - 169 + } else if x == 170 { + return x - 170 + } else if x == 171 { + return x - 171 + } else if x == 172 { + return x - 172 + } else if x == 173 { + return x - 173 + } else if x == 174 { + return x - 174 + } else if x == 175 { + return x - 175 + } else if x == 176 { + return x - 176 + } else if x == 177 { + return x - 177 + } else if x == 178 { + return x - 178 + } else if x == 179 { + return x - 179 + } else if x == 180 { + return x - 180 + } else if x == 181 { + return x - 181 + } else if x == 182 { + return x - 182 + } else if x == 183 { + return x - 183 + } else if x == 184 { + return x - 184 + } else if x == 185 { + return x - 185 + } else if x == 186 { + return x - 186 + } else if x == 187 { + return x - 187 + } else if x == 188 { + return x - 188 + } else if x == 189 { + return x - 189 + } else if x == 190 { + return x - 190 + } else if x == 191 { + return x - 191 + } +} \ No newline at end of file diff --git a/typed/benches/big_ternary.leo b/typed/benches/big_ternary.leo new file mode 100644 index 0000000000..34d8669aaf --- /dev/null +++ b/typed/benches/big_ternary.leo @@ -0,0 +1,5 @@ +function main() { + let x: u8 = 255; + + return if x == 0 ? x : (if x == 1 ? x : (if x == 2 ? x : (if x == 3 ? x : (if x == 4 ? x : (if x == 5 ? x : (if x == 6 ? x : (if x == 7 ? x : (if x == 8 ? x : (if x == 9 ? x : (if x == 10 ? x : (if x == 11 ? x : (if x == 12 ? x : (if x == 13 ? x : (if x == 14 ? x : (if x == 15 ? x : (if x == 16 ? x : (if x == 17 ? x : (if x == 18 ? x : (if x == 19 ? x : (if x == 20 ? x : (if x == 21 ? x : (if x == 22 ? x : (if x == 23 ? x : (if x == 24 ? x : (if x == 25 ? x : (if x == 26 ? x : (if x == 27 ? x : (if x == 28 ? x : (if x == 29 ? x : (if x == 30 ? x : (if x == 31 ? x : (if x == 32 ? x : (if x == 33 ? x : (if x == 34 ? x : (if x == 35 ? x : (if x == 36 ? x : (if x == 37 ? x : (if x == 38 ? x : (if x == 39 ? x : (if x == 40 ? x : (if x == 41 ? x : (if x == 42 ? x : (if x == 43 ? x : (if x == 44 ? x : (if x == 45 ? x : (if x == 46 ? x : (if x == 47 ? x : (if x == 48 ? x : (if x == 49 ? x : (if x == 50 ? x : (if x == 51 ? x : (if x == 52 ? x : (if x == 53 ? x : (if x == 54 ? x : (if x == 55 ? x : (if x == 56 ? x : (if x == 57 ? x : (if x == 58 ? x : (if x == 59 ? x : (if x == 60 ? x : (if x == 61 ? x : (if x == 62 ? x : (if x == 63 ? x : (if x == 64 ? x : (if x == 65 ? x : (if x == 66 ? x : (if x == 67 ? x : (if x == 68 ? x : (if x == 69 ? x : (if x == 70 ? x : (if x == 71 ? x : (if x == 72 ? x : (if x == 73 ? x : (if x == 74 ? x : (if x == 75 ? x : (if x == 76 ? x : (if x == 77 ? x : (if x == 78 ? x : (if x == 79 ? x : (if x == 80 ? x : (if x == 81 ? x : (if x == 82 ? x : (if x == 83 ? x : (if x == 84 ? x : (if x == 85 ? x : (if x == 86 ? x : (if x == 87 ? x : (if x == 88 ? x : (if x == 89 ? x : (if x == 90 ? x : (if x == 91 ? x : (if x == 92 ? x : (if x == 93 ? x : (if x == 94 ? x : (if x == 95 ? x : (if x == 96 ? x : (if x == 97 ? x : (if x == 98 ? x : (if x == 99 ? x : (if x == 100 ? x : (if x == 101 ? x : (if x == 102 ? x : (if x == 103 ? x : (if x == 104 ? x : (if x == 105 ? x : (if x == 106 ? x : (if x == 107 ? x : (if x == 108 ? x : (if x == 109 ? x : (if x == 110 ? x : (if x == 111 ? x : (if x == 112 ? x : (if x == 113 ? x : (if x == 114 ? x : (if x == 115 ? x : (if x == 116 ? x : (if x == 117 ? x : (if x == 118 ? x : (if x == 119 ? x : (if x == 120 ? x : (if x == 121 ? x : (if x == 122 ? x : (if x == 123 ? x : (if x == 124 ? x : (if x == 125 ? x : (if x == 126 ? x : (if x == 127 ? x : (if x == 128 ? x : (if x == 129 ? x : (if x == 130 ? x : (if x == 131 ? x : (if x == 132 ? x : (if x == 133 ? x : (if x == 134 ? x : (if x == 135 ? x : (if x == 136 ? x : (if x == 137 ? x : (if x == 138 ? x : (if x == 139 ? x : (if x == 140 ? x : (if x == 141 ? x : (if x == 142 ? x : (if x == 143 ? x : (if x == 144 ? x : (if x == 145 ? x : (if x == 146 ? x : (if x == 147 ? x : (if x == 148 ? x : (if x == 149 ? x : (if x == 150 ? x : (if x == 151 ? x : (if x == 152 ? x : (if x == 153 ? x : (if x == 154 ? x : (if x == 155 ? x : (if x == 156 ? x : (if x == 157 ? x : (if x == 158 ? x : (if x == 159 ? x : (if x == 160 ? x : (if x == 161 ? x : (if x == 162 ? x : (if x == 163 ? x : (if x == 164 ? x : (if x == 165 ? x : (if x == 166 ? x : (if x == 167 ? x : (if x == 168 ? x : (if x == 169 ? x : (if x == 170 ? x : (if x == 171 ? x : (if x == 172 ? x : (if x == 173 ? x : (if x == 174 ? x : (if x == 175 ? x : (if x == 176 ? x : (if x == 177 ? x : (if x == 178 ? x : (if x == 179 ? x : (if x == 180 ? x : (if x == 181 ? x : (if x == 182 ? x : (if x == 183 ? x : (if x == 184 ? x : (if x == 185 ? x : (if x == 186 ? x : (if x == 187 ? x : (if x == 188 ? x : (if x == 189 ? x : (if x == 190 ? x : (if x == 191 ? x : (if x == 192 ? x : (if x == 193 ? x : (if x == 194 ? x : (if x == 195 ? x : (if x == 196 ? x : (if x == 197 ? x : (if x == 198 ? x : (if x == 199 ? x : (if x == 200 ? x : (if x == 201 ? x : (if x == 202 ? x : (if x == 203 ? x : (if x == 204 ? x : (if x == 205 ? x : (if x == 206 ? x : (if x == 207 ? x : (if x == 208 ? x : (if x == 209 ? x : (if x == 210 ? x : (if x == 211 ? x : (if x == 212 ? x : (if x == 213 ? x : (if x == 214 ? x : (if x == 215 ? x : (if x == 216 ? x : (if x == 217 ? x : (if x == 218 ? x : (if x == 219 ? x : (if x == 220 ? x : (if x == 221 ? x : (if x == 222 ? x : (if x == 223 ? x : (if x == 224 ? x : (if x == 225 ? x : (if x == 226 ? x : (if x == 227 ? x : (if x == 228 ? x : (if x == 229 ? x : (if x == 230 ? x : (if x == 231 ? x : (if x == 232 ? x : (if x == 233 ? x : (if x == 234 ? x : (if x == 235 ? x : (if x == 236 ? x : (if x == 237 ? x : (if x == 238 ? x : (if x == 239 ? x : (if x == 240 ? x : (if x == 241 ? x : (if x == 242 ? x : (if x == 243 ? x : (if x == 244 ? x : (if x == 245 ? x : (if x == 246 ? x : (if x == 247 ? x : (if x == 248 ? x : (if x == 249 ? x : (if x == 250 ? x : (if x == 251 ? x : (if x == 252 ? x : (if x == 253 ? x : (if x == 254 ? x : (if x == 255 ? x : 0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) +} \ No newline at end of file diff --git a/typed/benches/long_array.leo b/typed/benches/long_array.leo new file mode 100644 index 0000000000..282feb66d0 --- /dev/null +++ b/typed/benches/long_array.leo @@ -0,0 +1,57 @@ +function main() { + let arr1: [u8; (32, 32)] = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31] + ]; + + let arr2: [u8; (16, 32)] = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31] + ]; + + return arr1[31][31] + arr2[15][31] +} diff --git a/typed/benches/long_expr.leo b/typed/benches/long_expr.leo new file mode 100644 index 0000000000..8cbfb99939 --- /dev/null +++ b/typed/benches/long_expr.leo @@ -0,0 +1,9 @@ +function main() { + let a = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + let b = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + let c = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + let d = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + let e = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + + return a + b + c + d + e +} diff --git a/typed/benches/main.leo b/typed/benches/main.leo deleted file mode 100644 index ef22115243..0000000000 --- a/typed/benches/main.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main() { - return 1 + 1 -} diff --git a/typed/benches/many_assigns.leo b/typed/benches/many_assigns.leo new file mode 100644 index 0000000000..8f174abc4b --- /dev/null +++ b/typed/benches/many_assigns.leo @@ -0,0 +1,388 @@ +function main() { + let x0: u8 = 0; + let x1: u8 = x0; + let x2: u8 = x1; + let x3: u8 = x2; + let x4: u8 = x3; + let x5: u8 = x4; + let x6: u8 = x5; + let x7: u8 = x6; + let x8: u8 = x7; + let x9: u8 = x8; + let x10: u8 = x9; + let x11: u8 = x10; + let x12: u8 = x11; + let x13: u8 = x12; + let x14: u8 = x13; + let x15: u8 = x14; + let x16: u8 = x15; + let x17: u8 = x16; + let x18: u8 = x17; + let x19: u8 = x18; + let x20: u8 = x19; + let x21: u8 = x20; + let x22: u8 = x21; + let x23: u8 = x22; + let x24: u8 = x23; + let x25: u8 = x24; + let x26: u8 = x25; + let x27: u8 = x26; + let x28: u8 = x27; + let x29: u8 = x28; + let x30: u8 = x29; + let x31: u8 = x30; + let x32: u8 = x31; + let x33: u8 = x32; + let x34: u8 = x33; + let x35: u8 = x34; + let x36: u8 = x35; + let x37: u8 = x36; + let x38: u8 = x37; + let x39: u8 = x38; + let x40: u8 = x39; + let x41: u8 = x40; + let x42: u8 = x41; + let x43: u8 = x42; + let x44: u8 = x43; + let x45: u8 = x44; + let x46: u8 = x45; + let x47: u8 = x46; + let x48: u8 = x47; + let x49: u8 = x48; + let x50: u8 = x49; + let x51: u8 = x50; + let x52: u8 = x51; + let x53: u8 = x52; + let x54: u8 = x53; + let x55: u8 = x54; + let x56: u8 = x55; + let x57: u8 = x56; + let x58: u8 = x57; + let x59: u8 = x58; + let x60: u8 = x59; + let x61: u8 = x60; + let x62: u8 = x61; + let x63: u8 = x62; + let x64: u8 = x63; + let x65: u8 = x64; + let x66: u8 = x65; + let x67: u8 = x66; + let x68: u8 = x67; + let x69: u8 = x68; + let x70: u8 = x69; + let x71: u8 = x70; + let x72: u8 = x71; + let x73: u8 = x72; + let x74: u8 = x73; + let x75: u8 = x74; + let x76: u8 = x75; + let x77: u8 = x76; + let x78: u8 = x77; + let x79: u8 = x78; + let x80: u8 = x79; + let x81: u8 = x80; + let x82: u8 = x81; + let x83: u8 = x82; + let x84: u8 = x83; + let x85: u8 = x84; + let x86: u8 = x85; + let x87: u8 = x86; + let x88: u8 = x87; + let x89: u8 = x88; + let x90: u8 = x89; + let x91: u8 = x90; + let x92: u8 = x91; + let x93: u8 = x92; + let x94: u8 = x93; + let x95: u8 = x94; + let x96: u8 = x95; + let x97: u8 = x96; + let x98: u8 = x97; + let x99: u8 = x98; + let x100: u8 = x99; + let x101: u8 = x100; + let x102: u8 = x101; + let x103: u8 = x102; + let x104: u8 = x103; + let x105: u8 = x104; + let x106: u8 = x105; + let x107: u8 = x106; + let x108: u8 = x107; + let x109: u8 = x108; + let x110: u8 = x109; + let x111: u8 = x110; + let x112: u8 = x111; + let x113: u8 = x112; + let x114: u8 = x113; + let x115: u8 = x114; + let x116: u8 = x115; + let x117: u8 = x116; + let x118: u8 = x117; + let x119: u8 = x118; + let x120: u8 = x119; + let x121: u8 = x120; + let x122: u8 = x121; + let x123: u8 = x122; + let x124: u8 = x123; + let x125: u8 = x124; + let x126: u8 = x125; + let x127: u8 = x126; + let x128: u8 = x127; + let x129: u8 = x128; + let x130: u8 = x129; + let x131: u8 = x130; + let x132: u8 = x131; + let x133: u8 = x132; + let x134: u8 = x133; + let x135: u8 = x134; + let x136: u8 = x135; + let x137: u8 = x136; + let x138: u8 = x137; + let x139: u8 = x138; + let x140: u8 = x139; + let x141: u8 = x140; + let x142: u8 = x141; + let x143: u8 = x142; + let x144: u8 = x143; + let x145: u8 = x144; + let x146: u8 = x145; + let x147: u8 = x146; + let x148: u8 = x147; + let x149: u8 = x148; + let x150: u8 = x149; + let x151: u8 = x150; + let x152: u8 = x151; + let x153: u8 = x152; + let x154: u8 = x153; + let x155: u8 = x154; + let x156: u8 = x155; + let x157: u8 = x156; + let x158: u8 = x157; + let x159: u8 = x158; + let x160: u8 = x159; + let x161: u8 = x160; + let x162: u8 = x161; + let x163: u8 = x162; + let x164: u8 = x163; + let x165: u8 = x164; + let x166: u8 = x165; + let x167: u8 = x166; + let x168: u8 = x167; + let x169: u8 = x168; + let x170: u8 = x169; + let x171: u8 = x170; + let x172: u8 = x171; + let x173: u8 = x172; + let x174: u8 = x173; + let x175: u8 = x174; + let x176: u8 = x175; + let x177: u8 = x176; + let x178: u8 = x177; + let x179: u8 = x178; + let x180: u8 = x179; + let x181: u8 = x180; + let x182: u8 = x181; + let x183: u8 = x182; + let x184: u8 = x183; + let x185: u8 = x184; + let x186: u8 = x185; + let x187: u8 = x186; + let x188: u8 = x187; + let x189: u8 = x188; + let x190: u8 = x189; + let x191: u8 = x190; + let x192: u8 = x191; + let x193: u8 = x192; + let x194: u8 = x193; + let x195: u8 = x194; + let x196: u8 = x195; + let x197: u8 = x196; + let x198: u8 = x197; + let x199: u8 = x198; + let x200: u8 = x199; + let x201: u8 = x200; + let x202: u8 = x201; + let x203: u8 = x202; + let x204: u8 = x203; + let x205: u8 = x204; + let x206: u8 = x205; + let x207: u8 = x206; + let x208: u8 = x207; + let x209: u8 = x208; + let x210: u8 = x209; + let x211: u8 = x210; + let x212: u8 = x211; + let x213: u8 = x212; + let x214: u8 = x213; + let x215: u8 = x214; + let x216: u8 = x215; + let x217: u8 = x216; + let x218: u8 = x217; + let x219: u8 = x218; + let x220: u8 = x219; + let x221: u8 = x220; + let x222: u8 = x221; + let x223: u8 = x222; + let x224: u8 = x223; + let x225: u8 = x224; + let x226: u8 = x225; + let x227: u8 = x226; + let x228: u8 = x227; + let x229: u8 = x228; + let x230: u8 = x229; + let x231: u8 = x230; + let x232: u8 = x231; + let x233: u8 = x232; + let x234: u8 = x233; + let x235: u8 = x234; + let x236: u8 = x235; + let x237: u8 = x236; + let x238: u8 = x237; + let x239: u8 = x238; + let x240: u8 = x239; + let x241: u8 = x240; + let x242: u8 = x241; + let x243: u8 = x242; + let x244: u8 = x243; + let x245: u8 = x244; + let x246: u8 = x245; + let x247: u8 = x246; + let x248: u8 = x247; + let x249: u8 = x248; + let x250: u8 = x249; + let x251: u8 = x250; + let x252: u8 = x251; + let x253: u8 = x252; + let x254: u8 = x253; + let x255: u8 = x254; + let x256: u8 = x255; + let x257: u8 = x256; + let x258: u8 = x257; + let x259: u8 = x258; + let x260: u8 = x259; + let x261: u8 = x260; + let x262: u8 = x261; + let x263: u8 = x262; + let x264: u8 = x263; + let x265: u8 = x264; + let x266: u8 = x265; + let x267: u8 = x266; + let x268: u8 = x267; + let x269: u8 = x268; + let x270: u8 = x269; + let x271: u8 = x270; + let x272: u8 = x271; + let x273: u8 = x272; + let x274: u8 = x273; + let x275: u8 = x274; + let x276: u8 = x275; + let x277: u8 = x276; + let x278: u8 = x277; + let x279: u8 = x278; + let x280: u8 = x279; + let x281: u8 = x280; + let x282: u8 = x281; + let x283: u8 = x282; + let x284: u8 = x283; + let x285: u8 = x284; + let x286: u8 = x285; + let x287: u8 = x286; + let x288: u8 = x287; + let x289: u8 = x288; + let x290: u8 = x289; + let x291: u8 = x290; + let x292: u8 = x291; + let x293: u8 = x292; + let x294: u8 = x293; + let x295: u8 = x294; + let x296: u8 = x295; + let x297: u8 = x296; + let x298: u8 = x297; + let x299: u8 = x298; + let x300: u8 = x299; + let x301: u8 = x300; + let x302: u8 = x301; + let x303: u8 = x302; + let x304: u8 = x303; + let x305: u8 = x304; + let x306: u8 = x305; + let x307: u8 = x306; + let x308: u8 = x307; + let x309: u8 = x308; + let x310: u8 = x309; + let x311: u8 = x310; + let x312: u8 = x311; + let x313: u8 = x312; + let x314: u8 = x313; + let x315: u8 = x314; + let x316: u8 = x315; + let x317: u8 = x316; + let x318: u8 = x317; + let x319: u8 = x318; + let x320: u8 = x319; + let x321: u8 = x320; + let x322: u8 = x321; + let x323: u8 = x322; + let x324: u8 = x323; + let x325: u8 = x324; + let x326: u8 = x325; + let x327: u8 = x326; + let x328: u8 = x327; + let x329: u8 = x328; + let x330: u8 = x329; + let x331: u8 = x330; + let x332: u8 = x331; + let x333: u8 = x332; + let x334: u8 = x333; + let x335: u8 = x334; + let x336: u8 = x335; + let x337: u8 = x336; + let x338: u8 = x337; + let x339: u8 = x338; + let x340: u8 = x339; + let x341: u8 = x340; + let x342: u8 = x341; + let x343: u8 = x342; + let x344: u8 = x343; + let x345: u8 = x344; + let x346: u8 = x345; + let x347: u8 = x346; + let x348: u8 = x347; + let x349: u8 = x348; + let x350: u8 = x349; + let x351: u8 = x350; + let x352: u8 = x351; + let x353: u8 = x352; + let x354: u8 = x353; + let x355: u8 = x354; + let x356: u8 = x355; + let x357: u8 = x356; + let x358: u8 = x357; + let x359: u8 = x358; + let x360: u8 = x359; + let x361: u8 = x360; + let x362: u8 = x361; + let x363: u8 = x362; + let x364: u8 = x363; + let x365: u8 = x364; + let x366: u8 = x365; + let x367: u8 = x366; + let x368: u8 = x367; + let x369: u8 = x368; + let x370: u8 = x369; + let x371: u8 = x370; + let x372: u8 = x371; + let x373: u8 = x372; + let x374: u8 = x373; + let x375: u8 = x374; + let x376: u8 = x375; + let x377: u8 = x376; + let x378: u8 = x377; + let x379: u8 = x378; + let x380: u8 = x379; + let x381: u8 = x380; + let x382: u8 = x381; + let x383: u8 = x382; + + return x383 +} diff --git a/typed/benches/many_foos.leo b/typed/benches/many_foos.leo new file mode 100644 index 0000000000..099f04857d --- /dev/null +++ b/typed/benches/many_foos.leo @@ -0,0 +1,196 @@ +function main() { + return x191(0u32) +} + +function x0(val: u8) -> u8 { return val } +function x1(val: u8) -> u8 { return x0(val) } +function x2(val: u8) -> u8 { return x1(val) } +function x3(val: u8) -> u8 { return x2(val) } +function x4(val: u8) -> u8 { return x3(val) } +function x5(val: u8) -> u8 { return x4(val) } +function x6(val: u8) -> u8 { return x5(val) } +function x7(val: u8) -> u8 { return x6(val) } +function x8(val: u8) -> u8 { return x7(val) } +function x9(val: u8) -> u8 { return x8(val) } +function x10(val: u8) -> u8 { return x9(val) } +function x11(val: u8) -> u8 { return x10(val) } +function x12(val: u8) -> u8 { return x11(val) } +function x13(val: u8) -> u8 { return x12(val) } +function x14(val: u8) -> u8 { return x13(val) } +function x15(val: u8) -> u8 { return x14(val) } +function x16(val: u8) -> u8 { return x15(val) } +function x17(val: u8) -> u8 { return x16(val) } +function x18(val: u8) -> u8 { return x17(val) } +function x19(val: u8) -> u8 { return x18(val) } +function x20(val: u8) -> u8 { return x19(val) } +function x21(val: u8) -> u8 { return x20(val) } +function x22(val: u8) -> u8 { return x21(val) } +function x23(val: u8) -> u8 { return x22(val) } +function x24(val: u8) -> u8 { return x23(val) } +function x25(val: u8) -> u8 { return x24(val) } +function x26(val: u8) -> u8 { return x25(val) } +function x27(val: u8) -> u8 { return x26(val) } +function x28(val: u8) -> u8 { return x27(val) } +function x29(val: u8) -> u8 { return x28(val) } +function x30(val: u8) -> u8 { return x29(val) } +function x31(val: u8) -> u8 { return x30(val) } +function x32(val: u8) -> u8 { return x31(val) } +function x33(val: u8) -> u8 { return x32(val) } +function x34(val: u8) -> u8 { return x33(val) } +function x35(val: u8) -> u8 { return x34(val) } +function x36(val: u8) -> u8 { return x35(val) } +function x37(val: u8) -> u8 { return x36(val) } +function x38(val: u8) -> u8 { return x37(val) } +function x39(val: u8) -> u8 { return x38(val) } +function x40(val: u8) -> u8 { return x39(val) } +function x41(val: u8) -> u8 { return x40(val) } +function x42(val: u8) -> u8 { return x41(val) } +function x43(val: u8) -> u8 { return x42(val) } +function x44(val: u8) -> u8 { return x43(val) } +function x45(val: u8) -> u8 { return x44(val) } +function x46(val: u8) -> u8 { return x45(val) } +function x47(val: u8) -> u8 { return x46(val) } +function x48(val: u8) -> u8 { return x47(val) } +function x49(val: u8) -> u8 { return x48(val) } +function x50(val: u8) -> u8 { return x49(val) } +function x51(val: u8) -> u8 { return x50(val) } +function x52(val: u8) -> u8 { return x51(val) } +function x53(val: u8) -> u8 { return x52(val) } +function x54(val: u8) -> u8 { return x53(val) } +function x55(val: u8) -> u8 { return x54(val) } +function x56(val: u8) -> u8 { return x55(val) } +function x57(val: u8) -> u8 { return x56(val) } +function x58(val: u8) -> u8 { return x57(val) } +function x59(val: u8) -> u8 { return x58(val) } +function x60(val: u8) -> u8 { return x59(val) } +function x61(val: u8) -> u8 { return x60(val) } +function x62(val: u8) -> u8 { return x61(val) } +function x63(val: u8) -> u8 { return x62(val) } +function x64(val: u8) -> u8 { return x63(val) } +function x65(val: u8) -> u8 { return x64(val) } +function x66(val: u8) -> u8 { return x65(val) } +function x67(val: u8) -> u8 { return x66(val) } +function x68(val: u8) -> u8 { return x67(val) } +function x69(val: u8) -> u8 { return x68(val) } +function x70(val: u8) -> u8 { return x69(val) } +function x71(val: u8) -> u8 { return x70(val) } +function x72(val: u8) -> u8 { return x71(val) } +function x73(val: u8) -> u8 { return x72(val) } +function x74(val: u8) -> u8 { return x73(val) } +function x75(val: u8) -> u8 { return x74(val) } +function x76(val: u8) -> u8 { return x75(val) } +function x77(val: u8) -> u8 { return x76(val) } +function x78(val: u8) -> u8 { return x77(val) } +function x79(val: u8) -> u8 { return x78(val) } +function x80(val: u8) -> u8 { return x79(val) } +function x81(val: u8) -> u8 { return x80(val) } +function x82(val: u8) -> u8 { return x81(val) } +function x83(val: u8) -> u8 { return x82(val) } +function x84(val: u8) -> u8 { return x83(val) } +function x85(val: u8) -> u8 { return x84(val) } +function x86(val: u8) -> u8 { return x85(val) } +function x87(val: u8) -> u8 { return x86(val) } +function x88(val: u8) -> u8 { return x87(val) } +function x89(val: u8) -> u8 { return x88(val) } +function x90(val: u8) -> u8 { return x89(val) } +function x91(val: u8) -> u8 { return x90(val) } +function x92(val: u8) -> u8 { return x91(val) } +function x93(val: u8) -> u8 { return x92(val) } +function x94(val: u8) -> u8 { return x93(val) } +function x95(val: u8) -> u8 { return x94(val) } +function x96(val: u8) -> u8 { return x95(val) } +function x97(val: u8) -> u8 { return x96(val) } +function x98(val: u8) -> u8 { return x97(val) } +function x99(val: u8) -> u8 { return x98(val) } +function x100(val: u8) -> u8 { return x99(val) } +function x101(val: u8) -> u8 { return x100(val) } +function x102(val: u8) -> u8 { return x101(val) } +function x103(val: u8) -> u8 { return x102(val) } +function x104(val: u8) -> u8 { return x103(val) } +function x105(val: u8) -> u8 { return x104(val) } +function x106(val: u8) -> u8 { return x105(val) } +function x107(val: u8) -> u8 { return x106(val) } +function x108(val: u8) -> u8 { return x107(val) } +function x109(val: u8) -> u8 { return x108(val) } +function x110(val: u8) -> u8 { return x109(val) } +function x111(val: u8) -> u8 { return x110(val) } +function x112(val: u8) -> u8 { return x111(val) } +function x113(val: u8) -> u8 { return x112(val) } +function x114(val: u8) -> u8 { return x113(val) } +function x115(val: u8) -> u8 { return x114(val) } +function x116(val: u8) -> u8 { return x115(val) } +function x117(val: u8) -> u8 { return x116(val) } +function x118(val: u8) -> u8 { return x117(val) } +function x119(val: u8) -> u8 { return x118(val) } +function x120(val: u8) -> u8 { return x119(val) } +function x121(val: u8) -> u8 { return x120(val) } +function x122(val: u8) -> u8 { return x121(val) } +function x123(val: u8) -> u8 { return x122(val) } +function x124(val: u8) -> u8 { return x123(val) } +function x125(val: u8) -> u8 { return x124(val) } +function x126(val: u8) -> u8 { return x125(val) } +function x127(val: u8) -> u8 { return x126(val) } +function x128(val: u8) -> u8 { return x127(val) } +function x129(val: u8) -> u8 { return x128(val) } +function x130(val: u8) -> u8 { return x129(val) } +function x131(val: u8) -> u8 { return x130(val) } +function x132(val: u8) -> u8 { return x131(val) } +function x133(val: u8) -> u8 { return x132(val) } +function x134(val: u8) -> u8 { return x133(val) } +function x135(val: u8) -> u8 { return x134(val) } +function x136(val: u8) -> u8 { return x135(val) } +function x137(val: u8) -> u8 { return x136(val) } +function x138(val: u8) -> u8 { return x137(val) } +function x139(val: u8) -> u8 { return x138(val) } +function x140(val: u8) -> u8 { return x139(val) } +function x141(val: u8) -> u8 { return x140(val) } +function x142(val: u8) -> u8 { return x141(val) } +function x143(val: u8) -> u8 { return x142(val) } +function x144(val: u8) -> u8 { return x143(val) } +function x145(val: u8) -> u8 { return x144(val) } +function x146(val: u8) -> u8 { return x145(val) } +function x147(val: u8) -> u8 { return x146(val) } +function x148(val: u8) -> u8 { return x147(val) } +function x149(val: u8) -> u8 { return x148(val) } +function x150(val: u8) -> u8 { return x149(val) } +function x151(val: u8) -> u8 { return x150(val) } +function x152(val: u8) -> u8 { return x151(val) } +function x153(val: u8) -> u8 { return x152(val) } +function x154(val: u8) -> u8 { return x153(val) } +function x155(val: u8) -> u8 { return x154(val) } +function x156(val: u8) -> u8 { return x155(val) } +function x157(val: u8) -> u8 { return x156(val) } +function x158(val: u8) -> u8 { return x157(val) } +function x159(val: u8) -> u8 { return x158(val) } +function x160(val: u8) -> u8 { return x159(val) } +function x161(val: u8) -> u8 { return x160(val) } +function x162(val: u8) -> u8 { return x161(val) } +function x163(val: u8) -> u8 { return x162(val) } +function x164(val: u8) -> u8 { return x163(val) } +function x165(val: u8) -> u8 { return x164(val) } +function x166(val: u8) -> u8 { return x165(val) } +function x167(val: u8) -> u8 { return x166(val) } +function x168(val: u8) -> u8 { return x167(val) } +function x169(val: u8) -> u8 { return x168(val) } +function x170(val: u8) -> u8 { return x169(val) } +function x171(val: u8) -> u8 { return x170(val) } +function x172(val: u8) -> u8 { return x171(val) } +function x173(val: u8) -> u8 { return x172(val) } +function x174(val: u8) -> u8 { return x173(val) } +function x175(val: u8) -> u8 { return x174(val) } +function x176(val: u8) -> u8 { return x175(val) } +function x177(val: u8) -> u8 { return x176(val) } +function x178(val: u8) -> u8 { return x177(val) } +function x179(val: u8) -> u8 { return x178(val) } +function x180(val: u8) -> u8 { return x179(val) } +function x181(val: u8) -> u8 { return x180(val) } +function x182(val: u8) -> u8 { return x181(val) } +function x183(val: u8) -> u8 { return x182(val) } +function x184(val: u8) -> u8 { return x183(val) } +function x185(val: u8) -> u8 { return x184(val) } +function x186(val: u8) -> u8 { return x185(val) } +function x187(val: u8) -> u8 { return x186(val) } +function x188(val: u8) -> u8 { return x187(val) } +function x189(val: u8) -> u8 { return x188(val) } +function x190(val: u8) -> u8 { return x189(val) } +function x191(val: u8) -> u8 { return x190(val) } diff --git a/typed/benches/typed_ast.rs b/typed/benches/typed_ast.rs index a38aa47238..06d5053be9 100644 --- a/typed/benches/typed_ast.rs +++ b/typed/benches/typed_ast.rs @@ -17,22 +17,81 @@ use leo_ast::{errors::ParserError, files::File, LeoAst}; use leo_typed::LeoTypedAst; -use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use std::path::{Path, PathBuf}; +use criterion::{criterion_group, criterion_main, Criterion}; +use std::{ + path::{Path, PathBuf}, + time::Duration, +}; -fn leo_typed_ast<'ast>(ast: &LeoAst<'ast>) { - let typed_ast = LeoTypedAst::new("leo_typed_tree", &ast); - black_box(typed_ast); +fn leo_typed_ast<'ast>(ast: &LeoAst<'ast>) -> LeoTypedAst { + LeoTypedAst::new("leo_typed_tree", &ast) } -fn criterion_benchmark(c: &mut Criterion) { - let filepath = Path::new("./main.leo").to_path_buf(); - // let program_string = &LeoAst::load_file(&filepath).unwrap(); - let program_string = include_str!("./main.leo"); +fn bench_big_if_else(c: &mut Criterion) { + let filepath = Path::new("./big_if_else.leo").to_path_buf(); + let program_string = include_str!("./big_if_else.leo"); let ast = LeoAst::new(&filepath, program_string).unwrap(); - c.bench_function("LeoTypedAst::new", |b| b.iter(|| leo_typed_ast(black_box(&ast)))); + c.bench_function("LeoTypedAst::big_if_else", |b| b.iter(|| leo_typed_ast(&ast))); } -criterion_group!(benches, criterion_benchmark); +fn bench_big_ternary(c: &mut Criterion) { + let filepath = Path::new("./big_ternary.leo").to_path_buf(); + let program_string = include_str!("./big_ternary.leo"); + let ast = LeoAst::new(&filepath, program_string).unwrap(); + + c.bench_function("LeoTypedAst::big_ternary", |b| b.iter(|| leo_typed_ast(&ast))); +} + +fn bench_big_circuit(c: &mut Criterion) { + let filepath = Path::new("./big_circuit.leo").to_path_buf(); + let program_string = include_str!("./big_circuit.leo"); + let ast = LeoAst::new(&filepath, program_string).unwrap(); + + c.bench_function("LeoTypedAst::big_circuit", |b| b.iter(|| leo_typed_ast(&ast))); +} + +fn bench_long_expr(c: &mut Criterion) { + let filepath = Path::new("./long_expr.leo").to_path_buf(); + let program_string = include_str!("./long_expr.leo"); + let ast = LeoAst::new(&filepath, program_string).unwrap(); + + c.bench_function("LeoTypedAst::long_expr", |b| b.iter(|| leo_typed_ast(&ast))); +} + +fn bench_long_array(c: &mut Criterion) { + let filepath = Path::new("./long_array.leo").to_path_buf(); + let program_string = include_str!("./long_array.leo"); + let ast = LeoAst::new(&filepath, program_string).unwrap(); + + c.bench_function("LeoTypedAst::long_array", |b| b.iter(|| leo_typed_ast(&ast))); +} + +fn bench_many_foos(c: &mut Criterion) { + let filepath = Path::new("./many_foos.leo").to_path_buf(); + let program_string = include_str!("./many_foos.leo"); + let ast = LeoAst::new(&filepath, program_string).unwrap(); + + c.bench_function("LeoTypedAst::many_foos", |b| b.iter(|| leo_typed_ast(&ast))); +} + +fn bench_many_assigns(c: &mut Criterion) { + let filepath = Path::new("./many_assigns.leo").to_path_buf(); + let program_string = include_str!("./many_assigns.leo"); + let ast = LeoAst::new(&filepath, program_string).unwrap(); + + c.bench_function("LeoTypedAst::many_assigns", |b| b.iter(|| leo_typed_ast(&ast))); +} + +criterion_group!( + name = benches; + config = Criterion::default().sample_size(200).measurement_time(Duration::from_secs(10)).nresamples(200_000); + targets = bench_big_circuit, + bench_long_expr, + bench_big_if_else, + bench_big_ternary, + bench_long_array, + bench_many_assigns, + bench_many_foos, +); criterion_main!(benches); From c8299743b8c2eadad79838aef3bd7f2f80a0a981 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 7 Oct 2020 12:20:49 +0200 Subject: [PATCH 09/13] perf: reduce Expression size from 244B to 152B Signed-off-by: ljedrz --- compiler/src/expression/expression.rs | 2 +- typed/src/expression.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/expression/expression.rs b/compiler/src/expression/expression.rs index 3304c2725d..d79416fd4d 100644 --- a/compiler/src/expression/expression.rs +++ b/compiler/src/expression/expression.rs @@ -54,7 +54,7 @@ impl> ConstrainedProgram { Expression::Address(address, span) => Ok(ConstrainedValue::Address(Address::constant(address, span)?)), Expression::Boolean(boolean, span) => Ok(ConstrainedValue::Boolean(new_bool_constant(boolean, span)?)), Expression::Field(field, span) => Ok(ConstrainedValue::Field(FieldType::constant(field, span)?)), - Expression::Group(group_element) => Ok(ConstrainedValue::Group(G::constant(group_element)?)), + Expression::Group(group_element) => Ok(ConstrainedValue::Group(G::constant(*group_element)?)), Expression::Implicit(value, span) => Ok(enforce_number_implicit(expected_type, value, span)?), Expression::Integer(type_, integer, span) => { Ok(ConstrainedValue::Integer(Integer::new_constant(&type_, integer, span)?)) diff --git a/typed/src/expression.rs b/typed/src/expression.rs index 5fc2543c1a..cb6132bd8b 100644 --- a/typed/src/expression.rs +++ b/typed/src/expression.rs @@ -64,7 +64,7 @@ pub enum Expression { Address(String, Span), Boolean(String, Span), Field(String, Span), - Group(GroupValue), + Group(Box), Implicit(String, Span), Integer(IntegerType, String, Span), @@ -597,7 +597,7 @@ impl<'ast> From> for Expression { impl<'ast> From> for Expression { fn from(ast_group: AstGroupValue<'ast>) -> Self { - Expression::Group(GroupValue::from(ast_group)) + Expression::Group(Box::new(GroupValue::from(ast_group))) } } From a3fc39db92b3b7d53188c043656baaebe2529c35 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 8 Oct 2020 12:51:45 +0200 Subject: [PATCH 10/13] perf: hand-written Hash and PartialEq implementations for Span Signed-off-by: ljedrz --- typed/src/common/span.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/typed/src/common/span.rs b/typed/src/common/span.rs index b5af258eb2..5867b7bb8d 100644 --- a/typed/src/common/span.rs +++ b/typed/src/common/span.rs @@ -16,8 +16,9 @@ use pest::Span as AstSpan; use serde::{Deserialize, Serialize}; +use std::hash::{Hash, Hasher}; -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct Span { /// text of input string pub text: String, @@ -29,6 +30,22 @@ pub struct Span { pub end: usize, } +impl PartialEq for Span { + fn eq(&self, other: &Self) -> bool { + self.line == other.line && self.start == other.start && self.end == other.end + } +} + +impl Eq for Span {} + +impl Hash for Span { + fn hash(&self, state: &mut H) { + self.line.hash(state); + self.start.hash(state); + self.end.hash(state); + } +} + impl<'ast> From> for Span { fn from(span: AstSpan<'ast>) -> Self { let mut text = " ".to_string(); From 0d01520ea52b2a9ed7fc79891dc17214d43e6b61 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 8 Oct 2020 13:27:33 +0200 Subject: [PATCH 11/13] perf: hand-written PartialEq implementation for Function Signed-off-by: ljedrz --- typed/src/functions/function.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/typed/src/functions/function.rs b/typed/src/functions/function.rs index 4f52da175d..429ce5a62e 100644 --- a/typed/src/functions/function.rs +++ b/typed/src/functions/function.rs @@ -20,7 +20,7 @@ use leo_ast::functions::Function as AstFunction; use serde::{Deserialize, Serialize}; use std::fmt; -#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] pub struct Function { pub identifier: Identifier, pub input: Vec, @@ -29,6 +29,14 @@ pub struct Function { pub span: Span, } +impl PartialEq for Function { + fn eq(&self, other: &Self) -> bool { + self.identifier == other.identifier + } +} + +impl Eq for Function {} + impl<'ast> From> for Function { fn from(function: AstFunction<'ast>) -> Self { let function_name = Identifier::from(function.identifier); From d6b266f8bf4c580044df4a5785ab69b21d94d284 Mon Sep 17 00:00:00 2001 From: howardwu Date: Tue, 20 Oct 2020 18:19:12 -0700 Subject: [PATCH 12/13] Remove need for ssh key in CI --- .github/workflows/ci.yml | 24 ------------------------ .github/workflows/release-tests.yml | 16 ---------------- 2 files changed, 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6749f22c9f..8d12928e66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,14 +15,6 @@ jobs: - name: Checkout uses: actions/checkout@v1 - - name: Load snarkOS - run: | - mkdir ~/.ssh - echo "${{ secrets.SNARKOS_DEPLOY_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - eval $(ssh-agent -s) - ssh-add -k ~/.ssh/id_rsa - - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -53,14 +45,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Load snarkOS - run: | - mkdir ~/.ssh - echo "${{ secrets.SNARKOS_DEPLOY_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - eval $(ssh-agent -s) - ssh-add -k ~/.ssh/id_rsa - - name: Install Rust (${{ matrix.rust }}) uses: actions-rs/toolchain@v1 with: @@ -131,14 +115,6 @@ jobs: - name: Checkout uses: actions/checkout@v1 - - name: Load snarkOS - run: | - mkdir ~/.ssh - echo "${{ secrets.SNARKOS_DEPLOY_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - eval $(ssh-agent -s) - ssh-add -k ~/.ssh/id_rsa - - name: Install Rust uses: actions-rs/toolchain@v1 with: diff --git a/.github/workflows/release-tests.yml b/.github/workflows/release-tests.yml index f97ee3384e..cec684f7da 100644 --- a/.github/workflows/release-tests.yml +++ b/.github/workflows/release-tests.yml @@ -15,14 +15,6 @@ jobs: - name: Checkout uses: actions/checkout@v1 - - name: Load snarkOS - run: | - mkdir ~/.ssh - echo "${{ secrets.SNARKOS_DEPLOY_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - eval $(ssh-agent -s) - ssh-add -k ~/.ssh/id_rsa - - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -54,14 +46,6 @@ jobs: - name: Checkout uses: actions/checkout@v1 - - name: Load snarkOS - run: | - mkdir ~/.ssh - echo "${{ secrets.SNARKOS_DEPLOY_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - eval $(ssh-agent -s) - ssh-add -k ~/.ssh/id_rsa - - name: Install Rust uses: actions-rs/toolchain@v1 with: From d680aa6cfcc20c8e230f2d1401198375432c51ea Mon Sep 17 00:00:00 2001 From: collin Date: Tue, 20 Oct 2020 23:35:31 -0700 Subject: [PATCH 13/13] fix map formatting error --- typed/src/expression.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/typed/src/expression.rs b/typed/src/expression.rs index 6c4e33e807..c06289a803 100644 --- a/typed/src/expression.rs +++ b/typed/src/expression.rs @@ -339,11 +339,7 @@ impl<'ast> From> for Expression { let span = Span::from(function.span); Expression::FunctionCall( Box::new(acc), - function - .expressions - .into_iter() - .map(|expression| Expression::from(expression)) - .collect(), + function.expressions.into_iter().map(Expression::from).collect(), span, ) }