Skip to main content

BatchParserBuilder

Struct BatchParserBuilder 

Source
pub struct BatchParserBuilder { /* private fields */ }

Implementations§

Source§

impl BatchParserBuilder

Source

pub fn limits(self, limits: ParserLimits) -> Self

Source

pub fn cache_capacity(self, entries: usize, bytes: usize) -> Self

Set FIFO cache payload bounds. Zero entries disables retention.

Examples found in repository?
examples/parser_guard_bench.rs (line 159)
153fn main() {
154    println!("workload,iterations,sources,elapsed_ns,ns_per_parse,digest");
155    for c in corpus() {
156        let digest = semantic_digest(&c.formulas);
157        let builder = BatchParser::builder();
158        let builder = if let Ok(entries) = std::env::var("BENCH_CACHE_ENTRIES") {
159            builder.cache_capacity(entries.parse().unwrap(), usize::MAX)
160        } else {
161            builder
162        };
163        let mut batch = builder.build();
164        // Warm allocator, code and the full working set. Pre-existing token
165        // cache warmup is retained intentionally to reveal eviction thrashing.
166        let unique = c.name == "batch_unique_stream";
167        let warm_count = if unique {
168            4096
169        } else {
170            c.formulas.len().max(4096)
171        };
172        for i in 0..warm_count {
173            let other = unique.then(|| format!("=X{i}+Y{i}*$C$1"));
174            let f = other
175                .as_deref()
176                .unwrap_or(&c.formulas[i % c.formulas.len()]);
177            consume(if c.batch {
178                batch.parse(f).unwrap()
179            } else {
180                parse(f).unwrap()
181            });
182        }
183        let start = Instant::now();
184        for i in 0..c.iterations {
185            let f = black_box(&c.formulas[i % c.formulas.len()]);
186            consume(if c.batch {
187                batch.parse(f).unwrap()
188            } else {
189                parse(f).unwrap()
190            });
191        }
192        let elapsed = start.elapsed().as_nanos();
193        println!(
194            "{},{},{},{},{:.3},{:016x}",
195            c.name,
196            c.iterations,
197            c.formulas.len(),
198            elapsed,
199            elapsed as f64 / c.iterations as f64,
200            digest
201        );
202    }
203}
Source

pub fn include_whitespace(self, include: bool) -> Self

Source

pub fn with_volatility_classifier<F>(self, f: F) -> Self
where F: Fn(&str) -> bool + Send + Sync + 'static,

Source

pub fn dialect(self, dialect: FormulaDialect) -> Self

Source

pub fn build(self) -> BatchParser

Examples found in repository?
examples/parser_guard_bench.rs (line 163)
153fn main() {
154    println!("workload,iterations,sources,elapsed_ns,ns_per_parse,digest");
155    for c in corpus() {
156        let digest = semantic_digest(&c.formulas);
157        let builder = BatchParser::builder();
158        let builder = if let Ok(entries) = std::env::var("BENCH_CACHE_ENTRIES") {
159            builder.cache_capacity(entries.parse().unwrap(), usize::MAX)
160        } else {
161            builder
162        };
163        let mut batch = builder.build();
164        // Warm allocator, code and the full working set. Pre-existing token
165        // cache warmup is retained intentionally to reveal eviction thrashing.
166        let unique = c.name == "batch_unique_stream";
167        let warm_count = if unique {
168            4096
169        } else {
170            c.formulas.len().max(4096)
171        };
172        for i in 0..warm_count {
173            let other = unique.then(|| format!("=X{i}+Y{i}*$C$1"));
174            let f = other
175                .as_deref()
176                .unwrap_or(&c.formulas[i % c.formulas.len()]);
177            consume(if c.batch {
178                batch.parse(f).unwrap()
179            } else {
180                parse(f).unwrap()
181            });
182        }
183        let start = Instant::now();
184        for i in 0..c.iterations {
185            let f = black_box(&c.formulas[i % c.formulas.len()]);
186            consume(if c.batch {
187                batch.parse(f).unwrap()
188            } else {
189                parse(f).unwrap()
190            });
191        }
192        let elapsed = start.elapsed().as_nanos();
193        println!(
194            "{},{},{},{},{:.3},{:016x}",
195            c.name,
196            c.iterations,
197            c.formulas.len(),
198            elapsed,
199            elapsed as f64 / c.iterations as f64,
200            digest
201        );
202    }
203}

Trait Implementations§

Source§

impl Default for BatchParserBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.