From 5b619bc467ac566cbd3cb5ff619e1048e2bf7b0a Mon Sep 17 00:00:00 2001 From: Christoph Hegemann Date: Mon, 1 Jul 2024 06:26:10 +0200 Subject: [PATCH] clippy/cleanup --- .../scip-syntax/benches/symbol_parsing.rs | 20 +++++++++---------- .../crates/scip-syntax/src/evaluate.rs | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docker-images/syntax-highlighter/crates/scip-syntax/benches/symbol_parsing.rs b/docker-images/syntax-highlighter/crates/scip-syntax/benches/symbol_parsing.rs index 41edc5a1f2625..6a7d10fd7c846 100644 --- a/docker-images/syntax-highlighter/crates/scip-syntax/benches/symbol_parsing.rs +++ b/docker-images/syntax-highlighter/crates/scip-syntax/benches/symbol_parsing.rs @@ -1,5 +1,5 @@ use camino::Utf8Path; -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use scip_syntax::{io::read_index_from_file, scip_strict}; fn parse_symbols(symbols: &[&str]) { @@ -31,16 +31,16 @@ fn symbols_from_index(path: &str) -> impl Iterator { fn bench_symbol_parsing(c: &mut Criterion) { // let all_symbols: Vec = symbols_from_index("~/work/scip-indices/spring-framework-syntactic.scip").collect(); let all_symbols: Vec = symbols_from_index("/Users/creek/work/scip-indices/chromium-1.scip").collect(); - let symbol_count = all_symbols.len(); - let n = 10_000; - let symbols: Vec<&str> = all_symbols.iter().step_by(symbol_count / n).map(|s| s.as_str()).collect(); let mut group = c.benchmark_group("symbol parsing"); - group.bench_function("parse", |b| { - b.iter(|| parse_symbols(&symbols)) - }); - group.bench_function("parse_v2", |b| { - b.iter(|| parse_symbols_v2(&symbols)) - }); + for n in [10_000, 100_000, 1_000_000] { + let symbols: Vec<&str> = all_symbols.iter().take(n).map(|s| s.as_str()).collect(); + group.bench_with_input(BenchmarkId::new("parse_v1", n), &symbols, |b, syms| { + b.iter(|| parse_symbols(syms)) + }); + group.bench_with_input(BenchmarkId::new("parse_v2", n), &symbols, |b, syms| { + b.iter(|| parse_symbols_v2(syms)) + }); + } } criterion_group!(benches, bench_symbol_parsing); diff --git a/docker-images/syntax-highlighter/crates/scip-syntax/src/evaluate.rs b/docker-images/syntax-highlighter/crates/scip-syntax/src/evaluate.rs index 1b13071397842..0c9af0ee96a4e 100644 --- a/docker-images/syntax-highlighter/crates/scip-syntax/src/evaluate.rs +++ b/docker-images/syntax-highlighter/crates/scip-syntax/src/evaluate.rs @@ -736,7 +736,7 @@ impl SymbolFormatter { return sym; }; symbol.package = scip_strict::Package::default(); - return self.make_symbol_id(&symbol.to_string()); + self.make_symbol_id(&symbol.to_string()) } }