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

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.