Benchmark for KCL parser (#664)

* KCL benchmarks

* CI for benchmarks

* More specific name for benchmark

* Benchmark the right directory

* Format
This commit is contained in:
Adam Chalmers
2023-09-20 13:15:28 -05:00
committed by GitHub
parent ad482641ef
commit b67c16cc9d
7 changed files with 200 additions and 3 deletions

View File

@ -0,0 +1,27 @@
use criterion::{criterion_group, criterion_main, Criterion};
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("parse + lex cube program", |b| b.iter(lex_and_parse_cube));
}
fn lex_and_parse_cube() {
let program = r#"
fn cube = (pos, scale) => {
const sg = startSketchAt(pos)
|> line([0, scale], %)
|> line([scale, 0], %)
|> line([0, -scale], %)
return sg
}
const b1 = cube([0,0], 10)
const pt1 = b1[0]
show(b1)"#;
let tokens = kcl_lib::tokeniser::lexer(program);
let parser = kcl_lib::parser::Parser::new(tokens);
parser.ast().unwrap();
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);