Skip to content

Commit

Permalink
Add simple benchmark tool
Browse files Browse the repository at this point in the history
Since `#[bench]` is nightly-only, add a simple binary that can be
modified to test the performance of specific queries as needed.
  • Loading branch information
unflxw committed Dec 20, 2024
1 parent c9f793c commit f17159a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/bin/bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fn long_insert_into_values_query(rows: usize) -> String {
let mut query = r#"INSERT INTO "table_name" ("one","two","three") VALUES "#.to_owned();
for i in 0..rows {
query.push_str(&format!("({}, {}, {}),", i, i + 1, i + 2));
}
query.push_str("(0, 0, 0);");
query
}

extern crate sql_lexer;

fn main() {
for rows in [200, 2000, 20000] {
println!("Sanitising long_insert_into_values_query with {rows} rows");
let query = long_insert_into_values_query(rows);
let start = std::time::Instant::now();
let output = sql_lexer::sanitize_string(query);
let elapsed = start.elapsed();
println!("Output: {}", output);
println!("Elapsed: {:?}", elapsed);
}
}

0 comments on commit f17159a

Please sign in to comment.