Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/syn-2.0.119/benches/file.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / syn-2.0.119 / benches / file.rs` 59 lines ยท 1400 bytes Raw Blame History 1 // $ cargo bench --features full,test --bench file 2 3 #![feature(rustc_private, test)] 4 #![recursion_limit = "1024"] 5 #![allow( 6 clippy::elidable_lifetime_names, 7 clippy::items_after_statements, 8 clippy::manual_let_else, 9 clippy::match_like_matches_macro, 10 clippy::missing_panics_doc, 11 clippy::must_use_candidate, 12 clippy::needless_lifetimes, 13 clippy::uninlined_format_args 14 )] 15 16 extern crate test; 17 18 #[macro_use] 19 #[path = "../tests/macros/mod.rs"] 20 mod macros; 21 22 #[allow(dead_code)] 23 #[path = "../tests/repo/mod.rs"] 24 mod repo; 25 26 use proc_macro2::{Span, TokenStream}; 27 use std::fs; 28 use std::str::FromStr; 29 use syn::parse::{ParseStream, Parser}; 30 use test::Bencher; 31 32 const FILE: &str = "tests/rust/library/core/src/str/mod.rs"; 33 34 fn get_tokens() -> TokenStream { 35 repo::clone_rust(); 36 let content = fs::read_to_string(FILE).unwrap(); 37 TokenStream::from_str(&content).unwrap() 38 } 39 40 #[bench] 41 fn baseline(b: &mut Bencher) { 42 let tokens = get_tokens(); 43 b.iter(|| drop(tokens.clone())); 44 } 45 46 #[bench] 47 fn create_token_buffer(b: &mut Bencher) { 48 let tokens = get_tokens(); 49 fn immediate_fail(_input: ParseStream) -> syn::Result<()> { 50 Err(syn::Error::new(Span::call_site(), "")) 51 } 52 b.iter(|| immediate_fail.parse2(tokens.clone())); 53 } 54 55 #[bench] 56 fn parse_file(b: &mut Bencher) { 57 let tokens = get_tokens(); 58 b.iter(|| syn::parse2::(tokens.clone())); 59 }