mirror of
https://github.com/AleoHQ/leo.git
synced 2024-09-11 15:05:33 +03:00
Adds benchmarks for serialization
This commit is contained in:
parent
3ccfd2c764
commit
b81129db67
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
/target
|
**/target
|
||||||
/tmp/
|
/tmp/
|
||||||
**.idea/
|
**.idea/
|
||||||
outputs/
|
outputs/
|
||||||
|
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -758,6 +758,7 @@ version = "0.1.0"
|
|||||||
name = "leo-types"
|
name = "leo-types"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"criterion",
|
||||||
"leo-ast",
|
"leo-ast",
|
||||||
"leo-input",
|
"leo-input",
|
||||||
"pest",
|
"pest",
|
||||||
|
@ -8,6 +8,10 @@ edition = "2018"
|
|||||||
name = "leo_ast"
|
name = "leo_ast"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "ast"
|
||||||
|
harness = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
from-pest = { version = "0.3.1" }
|
from-pest = { version = "0.3.1" }
|
||||||
lazy_static = { version = "1.3.0" }
|
lazy_static = { version = "1.3.0" }
|
||||||
|
22
ast/benches/ast.rs
Normal file
22
ast/benches/ast.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
use leo_ast::{errors::ParserError, files::File, LeoAst};
|
||||||
|
|
||||||
|
use criterion::{black_box, 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 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)))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
3
ast/benches/main.leo
Normal file
3
ast/benches/main.leo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function main() {
|
||||||
|
return 1 + 1
|
||||||
|
}
|
@ -8,6 +8,10 @@ edition = "2018"
|
|||||||
name = "leo_types_ast"
|
name = "leo_types_ast"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "typed_ast"
|
||||||
|
harness = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
leo-ast = { path = "../ast", version = "0.1.0" }
|
leo-ast = { path = "../ast", version = "0.1.0" }
|
||||||
leo-input = { path = "../leo-input", version = "0.1.0" }
|
leo-input = { path = "../leo-input", version = "0.1.0" }
|
||||||
@ -19,6 +23,9 @@ pest = { version = "2.0" }
|
|||||||
serde = { version = "1.0" }
|
serde = { version = "1.0" }
|
||||||
serde_json = { version = "1.0" }
|
serde_json = { version = "1.0" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
criterion = { version = "0.3" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
ci_skip = ["leo-ast/ci_skip"]
|
ci_skip = ["leo-ast/ci_skip"]
|
||||||
|
3
types/benches/main.leo
Normal file
3
types/benches/main.leo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function main() {
|
||||||
|
return 1 + 1
|
||||||
|
}
|
22
types/benches/typed_ast.rs
Normal file
22
types/benches/typed_ast.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
use leo_ast::{errors::ParserError, files::File, LeoAst};
|
||||||
|
use leo_types::LeoTypedAst;
|
||||||
|
|
||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
fn leo_typed_ast<'ast>(ast: &LeoAst<'ast>) {
|
||||||
|
let typed_ast = LeoTypedAst::new("leo_typed_tree", &ast);
|
||||||
|
black_box(typed_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");
|
||||||
|
let ast = LeoAst::new(&filepath, program_string).unwrap();
|
||||||
|
|
||||||
|
c.bench_function("LeoTypedAst::new", |b| b.iter(|| leo_typed_ast(black_box(&ast))));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
Loading…
Reference in New Issue
Block a user