expry 0.4.0

Execute an expression on an encoded (binary) value, yielding another binary value (either in decoded or encoded form). Supports custom functions. Supports parsing the expression and converting the expression to bytecode.
Documentation
use std::{env, fs::File, io::{BufReader, Read}, time::{Instant, Duration}};

use expry::{*, memorypool::MemoryPool};

fn main() {
    let args : Vec<String> = env::args().collect();
    let f = File::open(args.get(1).map(|x| &x[..]).unwrap_or("twitter.json")).unwrap();
    let mut reader = BufReader::new(f);
    let mut bytes = String::new();
    reader.read_to_string(&mut bytes).unwrap();
    println!("read {} bytes", bytes.len());

    let before = Instant::now();
    let count = 256;
    let mut min_loop : Duration = Duration::MAX;
    for _ in 0..count {
        let before_loop_body = Instant::now();
        pool!(scope);
        // let parsed = expry_compile_typed(&bytes, None, None, &[], &std::collections::BTreeMap::new(), &mut scope);
        // if let Ok((bytecode,_dynamic,_return_type)) = &parsed {
        let parsed = expry_compile_expr(&bytes, None, None, &[], &mut scope);
        if let Ok((bytecode,_dynamic)) = &parsed {
            let _ = expry_eval(*bytecode, &mut Vec::new(), &mut scope);
        }
        let after_loop_body = Instant::now();
        assert!(parsed.is_ok());
        let dur = after_loop_body - before_loop_body;
        min_loop = Duration::min(min_loop, dur);
    }
    let after = Instant::now();
    let dur = after - before;

    println!("{}x in {} ms -> {} MB/s", count, dur.as_millis(), ((count*bytes.len()) as u128)/dur.as_micros());
    println!("fastest loop body in {} ms -> {} MB/s", min_loop.as_millis(), ((bytes.len()) as u128)/min_loop.as_micros());
}