use BufReader for counting zero bytes
This commit is contained in:
parent
34f888941e
commit
1be58056e1
2 changed files with 18 additions and 14 deletions
|
@ -40,7 +40,7 @@ use rustc_span::{
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::io::{Seek, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -734,12 +734,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
assert_eq!(total_bytes, computed_total_bytes);
|
assert_eq!(total_bytes, computed_total_bytes);
|
||||||
|
|
||||||
if tcx.sess.meta_stats() {
|
if tcx.sess.meta_stats() {
|
||||||
// let mut zero_bytes = 0;
|
let mut zero_bytes = 0;
|
||||||
// for e in self.opaque.data.iter() {
|
let file = std::io::BufReader::new(self.opaque.file());
|
||||||
// if *e == 0 {
|
for e in file.bytes() {
|
||||||
// zero_bytes += 1;
|
if e.unwrap() == 0 {
|
||||||
// }
|
zero_bytes += 1;
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let perc = |bytes| (bytes * 100) as f64 / total_bytes as f64;
|
let perc = |bytes| (bytes * 100) as f64 / total_bytes as f64;
|
||||||
let p = |label, bytes| {
|
let p = |label, bytes| {
|
||||||
|
@ -747,13 +748,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
eprintln!("");
|
eprintln!("");
|
||||||
// FIXME print zero bytes
|
eprintln!(
|
||||||
//eprintln!(
|
"{} metadata bytes, of which {} bytes ({:.1}%) are zero",
|
||||||
// "{} metadata bytes, of which {} bytes ({:.1}%) are zero",
|
total_bytes,
|
||||||
// total_bytes,
|
zero_bytes,
|
||||||
// zero_bytes,
|
perc(zero_bytes)
|
||||||
// perc(zero_bytes)
|
);
|
||||||
//);
|
|
||||||
p("preamble", preamble_bytes);
|
p("preamble", preamble_bytes);
|
||||||
p("dep", dep_bytes);
|
p("dep", dep_bytes);
|
||||||
p("lib feature", lib_feature_bytes);
|
p("lib feature", lib_feature_bytes);
|
||||||
|
|
|
@ -297,6 +297,10 @@ impl FileEncoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn file(&self) -> &File {
|
||||||
|
&self.file
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn capacity(&self) -> usize {
|
fn capacity(&self) -> usize {
|
||||||
self.buf.len()
|
self.buf.len()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue