Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run rustfmt 0.8.6 #205

Merged
merged 2 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 68 additions & 68 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ pub fn read_section(section: &str) -> Vec<u8> {
fn bench_parsing_debug_abbrev(b: &mut test::Bencher) {
let debug_info = read_section("debug_info");
let debug_info = DebugInfo::<LittleEndian>::new(&debug_info);
let unit = debug_info.units()
let unit = debug_info
.units()
.next()
.expect("Should have at least one compilation unit")
.expect("And it should parse OK");

let debug_abbrev = read_section("debug_abbrev");

b.iter(|| {
let debug_abbrev = DebugAbbrev::<LittleEndian>::new(&debug_abbrev);
test::black_box(unit.abbreviations(debug_abbrev)
.expect("Should parse abbreviations"));
});
let debug_abbrev = DebugAbbrev::<LittleEndian>::new(&debug_abbrev);
test::black_box(unit.abbreviations(debug_abbrev)
.expect("Should parse abbreviations"));
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh... I've tried to figure out how to fix this indentation behavior, haven't found anything that quite does the trick.

}

#[bench]
Expand Down Expand Up @@ -82,7 +83,8 @@ fn bench_parsing_debug_info_tree(b: &mut test::Bencher) {
let abbrevs = unit.abbreviations(debug_abbrev)
.expect("Should parse abbreviations");

let mut tree = unit.entries_tree(&abbrevs, None).expect("Should have entries tree");
let mut tree = unit.entries_tree(&abbrevs, None)
.expect("Should have entries tree");
parse_debug_info_tree(tree.iter());
}
});
Expand All @@ -107,11 +109,11 @@ fn bench_parsing_debug_aranges(b: &mut test::Bencher) {
let debug_aranges = DebugAranges::<LittleEndian>::new(&debug_aranges);

b.iter(|| {
let mut aranges = debug_aranges.items();
while let Some(arange) = aranges.next().expect("Should parse arange OK") {
test::black_box(arange);
}
});
let mut aranges = debug_aranges.items();
while let Some(arange) = aranges.next().expect("Should parse arange OK") {
test::black_box(arange);
}
});
}

#[bench]
Expand All @@ -120,11 +122,11 @@ fn bench_parsing_debug_pubnames(b: &mut test::Bencher) {
let debug_pubnames = DebugPubNames::<LittleEndian>::new(&debug_pubnames);

b.iter(|| {
let mut pubnames = debug_pubnames.items();
while let Some(pubname) = pubnames.next().expect("Should parse pubname OK") {
test::black_box(pubname);
}
});
let mut pubnames = debug_pubnames.items();
while let Some(pubname) = pubnames.next().expect("Should parse pubname OK") {
test::black_box(pubname);
}
});
}

#[bench]
Expand All @@ -133,11 +135,11 @@ fn bench_parsing_debug_types(b: &mut test::Bencher) {
let debug_pubtypes = DebugPubTypes::<LittleEndian>::new(&debug_pubtypes);

b.iter(|| {
let mut pubtypes = debug_pubtypes.items();
while let Some(pubtype) = pubtypes.next().expect("Should parse pubtype OK") {
test::black_box(pubtype);
}
});
let mut pubtypes = debug_pubtypes.items();
while let Some(pubtype) = pubtypes.next().expect("Should parse pubtype OK") {
test::black_box(pubtype);
}
});
}

// We happen to know that there is a line number program and header at
Expand All @@ -152,7 +154,8 @@ fn bench_parsing_line_number_program_opcodes(b: &mut test::Bencher) {
let debug_line = DebugLine::<LittleEndian>::new(&debug_line);

b.iter(|| {
let program = debug_line.program(OFFSET, ADDRESS_SIZE, None, None)
let program = debug_line
.program(OFFSET, ADDRESS_SIZE, None, None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why do these ones not get teh same indentation? ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behaviour is controlled by closure_block_indent_threshold, which defaults to 7 lines. So closures of up to 7 lines use visual, and longer closures use block indent. I'd be happy with a setting that made it use the same indentation always.

.expect("Should parse line number program header");
let header = program.header();

Expand All @@ -169,19 +172,21 @@ fn bench_executing_line_number_programs(b: &mut test::Bencher) {
let debug_line = DebugLine::<LittleEndian>::new(&debug_line);

b.iter(|| {
let program = debug_line.program(OFFSET, ADDRESS_SIZE, None, None)
let program = debug_line
.program(OFFSET, ADDRESS_SIZE, None, None)
.expect("Should parse line number program header");

let mut rows = program.rows();
while let Some(row) = rows.next_row()
.expect("Should parse and execute all rows in the line number program") {
while let Some(row) =
rows.next_row()
.expect("Should parse and execute all rows in the line number program") {
test::black_box(row);
}
});
}

// See comment above `test_parse_self_eh_frame`.
#[cfg(target_pointer_width="64")]
#[cfg(target_pointer_width = "64")]
mod cfi {
extern crate fallible_iterator;
extern crate gimli;
Expand All @@ -198,28 +203,22 @@ mod cfi {
let eh_frame = read_section("eh_frame");
let eh_frame = EhFrame::<LittleEndian>::new(&eh_frame);

let bases = BaseAddresses::default()
.set_cfi(0)
.set_data(0)
.set_text(0);
let bases = BaseAddresses::default().set_cfi(0).set_data(0).set_text(0);

b.iter(|| {
let mut entries = eh_frame.entries(&bases);
while let Some(entry) = entries.next().expect("Should parse CFI entry OK") {
test::black_box(entry);
}
});
let mut entries = eh_frame.entries(&bases);
while let Some(entry) = entries.next().expect("Should parse CFI entry OK") {
test::black_box(entry);
}
});
}

#[bench]
fn iterate_entries_and_parse_every_fde(b: &mut test::Bencher) {
let eh_frame = read_section("eh_frame");
let eh_frame = EhFrame::<LittleEndian>::new(&eh_frame);

let bases = BaseAddresses::default()
.set_cfi(0)
.set_data(0)
.set_text(0);
let bases = BaseAddresses::default().set_cfi(0).set_data(0).set_text(0);

b.iter(|| {
let mut entries = eh_frame.entries(&bases);
Expand All @@ -229,7 +228,8 @@ mod cfi {
test::black_box(cie);
}
CieOrFde::Fde(partial) => {
let fde = partial.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
let fde = partial
.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
.expect("Should be able to get CIE for FED");
test::black_box(fde);
}
Expand All @@ -243,28 +243,28 @@ mod cfi {
let eh_frame = read_section("eh_frame");
let eh_frame = EhFrame::<LittleEndian>::new(&eh_frame);

let bases = BaseAddresses::default()
.set_cfi(0)
.set_data(0)
.set_text(0);
let bases = BaseAddresses::default().set_cfi(0).set_data(0).set_text(0);

b.iter(|| {
let mut entries = eh_frame.entries(&bases);
while let Some(entry) = entries.next().expect("Should parse CFI entry OK") {
match entry {
CieOrFde::Cie(cie) => {
let mut instrs = cie.instructions();
while let Some(i) = instrs.next()
.expect("Can parse next CFI instruction OK") {
while let Some(i) = instrs
.next()
.expect("Can parse next CFI instruction OK") {
test::black_box(i);
}
}
CieOrFde::Fde(partial) => {
let fde = partial.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
let fde = partial
.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
.expect("Should be able to get CIE for FED");
let mut instrs = fde.instructions();
while let Some(i) = instrs.next()
.expect("Can parse next CFI instruction OK") {
while let Some(i) = instrs
.next()
.expect("Can parse next CFI instruction OK") {
test::black_box(i);
}
}
Expand All @@ -278,10 +278,7 @@ mod cfi {
let eh_frame = read_section("eh_frame");
let eh_frame = EhFrame::<LittleEndian>::new(&eh_frame);

let bases = BaseAddresses::default()
.set_cfi(0)
.set_data(0)
.set_text(0);
let bases = BaseAddresses::default().set_cfi(0).set_data(0).set_text(0);

let mut ctx = Some(UninitializedUnwindContext::new());

Expand All @@ -291,7 +288,8 @@ mod cfi {
match entry {
CieOrFde::Cie(_) => {}
CieOrFde::Fde(partial) => {
let fde = partial.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
let fde = partial
.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
.expect("Should be able to get CIE for FED");

let mut context = ctx.take()
Expand All @@ -301,8 +299,9 @@ mod cfi {

{
let mut table = UnwindTable::new(&mut context, &fde);
while let Some(row) = table.next_row()
.expect("Should get next unwind table row") {
while let Some(row) = table
.next_row()
.expect("Should get next unwind table row") {
test::black_box(row);
}
}
Expand All @@ -318,15 +317,15 @@ mod cfi {
LittleEndian,
EhFrame<'input, LittleEndian>>)
-> usize {
fde.instructions().fold(0, |count, _| count + 1).expect("fold over instructions OK")
fde.instructions()
.fold(0, |count, _| count + 1)
.expect("fold over instructions OK")
}

fn get_fde_with_longest_cfi_instructions(eh_frame: EhFrame<LittleEndian>)
fn get_fde_with_longest_cfi_instructions
(eh_frame: EhFrame<LittleEndian>)
-> FrameDescriptionEntry<LittleEndian, EhFrame<LittleEndian>> {
let bases = BaseAddresses::default()
.set_cfi(0)
.set_data(0)
.set_text(0);
let bases = BaseAddresses::default().set_cfi(0).set_data(0).set_text(0);

let mut longest: Option<(usize, FrameDescriptionEntry<_, _>)> = None;

Expand All @@ -335,7 +334,8 @@ mod cfi {
match entry {
CieOrFde::Cie(_) => {}
CieOrFde::Fde(partial) => {
let fde = partial.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
let fde = partial
.parse(|offset| eh_frame.cie_from_offset(&bases, offset))
.expect("Should be able to get CIE for FED");

let this_len = instrs_len(&fde);
Expand All @@ -362,11 +362,11 @@ mod cfi {
let fde = get_fde_with_longest_cfi_instructions(eh_frame);

b.iter(|| {
let mut instrs = fde.instructions();
while let Some(i) = instrs.next().expect("Should parse instruction OK") {
test::black_box(i);
}
});
let mut instrs = fde.instructions();
while let Some(i) = instrs.next().expect("Should parse instruction OK") {
test::black_box(i);
}
});
}

#[bench]
Expand Down
Loading