mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-19 10:24:16 +00:00
flush and assert when counting zero bytes
This commit is contained in:
parent
c57d778872
commit
7eb64b4901
@ -733,14 +733,18 @@ 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() {
|
||||||
|
self.opaque.flush().unwrap();
|
||||||
|
|
||||||
|
let pos_before_rewind = self.opaque.file().stream_position().unwrap();
|
||||||
let mut zero_bytes = 0;
|
let mut zero_bytes = 0;
|
||||||
self.opaque.file().seek(std::io::SeekFrom::Start(0)).unwrap();
|
self.opaque.file().rewind().unwrap();
|
||||||
let file = std::io::BufReader::new(self.opaque.file());
|
let file = std::io::BufReader::new(self.opaque.file());
|
||||||
for e in file.bytes() {
|
for e in file.bytes() {
|
||||||
if e.unwrap() == 0 {
|
if e.unwrap() == 0 {
|
||||||
zero_bytes += 1;
|
zero_bytes += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert_eq!(self.opaque.file().stream_position().unwrap(), pos_before_rewind);
|
||||||
|
|
||||||
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| {
|
||||||
|
Loading…
Reference in New Issue
Block a user