Closed dtolnay closed 2 months ago
cargo llvm-lines | head
use std::mem::{self, size_of}; use syn::fold::Fold; use syn::{File, Ident}; struct MyFold; impl Fold for MyFold { fn fold_ident(&mut self, i: Ident) -> Ident { println!("{}", i); i } } fn main() { let file: File = unsafe { mem::transmute([1usize; size_of::<File>() / size_of::<usize>()]) }; MyFold.fold_file(file); }
Before:
Lines Copies Function name ----- ------ ------------- 101619 2821 (TOTAL) 25088 (24.7%, 24.7%) 98 (3.5%, 3.5%) alloc::vec::in_place_collect::from_iter_in_place 11858 (11.7%, 36.4%) 98 (3.5%, 6.9%) core::iter::traits::iterator::Iterator::try_fold 6370 (6.3%, 42.6%) 98 (3.5%, 10.4%) core::iter::adapters::map::map_try_fold::{{closure}} 4658 (4.6%, 47.2%) 34 (1.2%, 11.6%) syn::punctuated::do_extend 4116 (4.1%, 51.3%) 98 (3.5%, 15.1%) <I as alloc::vec::in_place_collect::SpecInPlaceCollect<T,I>>::collect_in_place 3136 (3.1%, 54.3%) 98 (3.5%, 18.6%) <alloc::vec::Vec<T> as syn::gen::helper::fold::FoldHelper>::lift 2352 (2.3%, 56.7%) 103 (3.7%, 22.2%) core::option::Option<T>::map
After:
Lines Copies Function name ----- ------ ------------- 43627 1366 (TOTAL) 2352 (5.4%, 5.4%) 103 (7.5%, 7.5%) core::option::Option<T>::map 2329 (5.3%, 10.7%) 17 (1.2%, 8.8%) syn::punctuated::do_extend 1800 (4.1%, 14.9%) 20 (1.5%, 10.2%) <alloc::vec::Vec<T,A> as core::iter::traits::collect::IntoIterator>::into_iter 1792 (4.1%, 19.0%) 7 (0.5%, 10.8%) alloc::vec::in_place_collect::from_iter_in_place 1659 (3.8%, 22.8%) 21 (1.5%, 12.3%) <alloc::vec::into_iter::IntoIter<T,A> as core::iter::traits::iterator::Iterator>::next 1173 (2.7%, 25.5%) 17 (1.2%, 13.5%) <syn::punctuated::Punctuated<T,P> as syn::gen::helper::fold::FoldHelper>::lift::{{closure}} 960 (2.2%, 27.7%) 20 (1.5%, 15.0%) <alloc::vec::into_iter::IntoIter<T,A> as core::ops::drop::Drop>::drop
cargo llvm-lines | head
Before:
After: