/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
usecrate::NotifierEvent; usecrate::WindowWrapper; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::{BufRead, BufReader}; use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use std::sync::mpsc::Receiver; usecrate::wrench::{Wrench, WrenchThing}; usecrate::yaml_frame_reader::YamlFrameReader; use webrender::DebugFlags; use webrender::render_api::DebugCommand;
impl BenchmarkManifest { pubfn new(manifest: &Path) -> BenchmarkManifest { let dir = manifest.parent().unwrap(); let f =
File::open(manifest).unwrap_or_else(|_| panic!("couldn't open manifest: {}", manifest.display())); let file = BufReader::new(&f);
letmut benchmarks = Vec::new();
for line in file.lines() { let l = line.unwrap();
// strip the comments let s = &l[0 .. l.find('#').unwrap_or(l.len())]; let s = s.trim(); if s.is_empty() { continue;
}
letmut items = s.split_whitespace();
match items.next() {
Some("include") => { let include = dir.join(items.next().unwrap());
benchmarks.append(&mut BenchmarkManifest::new(include.as_path()).benchmarks);
}
Some(name) => { let test = dir.join(name);
benchmarks.push(Benchmark { test });
}
_ => panic!(),
};
}
// Loop until we get a reasonable number of CPU and GPU // frame profiles. Then take the mean. letmut cpu_frame_profiles = Vec::new(); letmut gpu_frame_profiles = Vec::new();
while cpu_frame_profiles.len() < self.sample_count ||
gpu_frame_profiles.len() < self.sample_count
{
reader.do_frame(self.wrench); self.rx.recv().unwrap(); self.wrench.render(); self.window.swap_buffers(); let (cpu_profiles, gpu_profiles) = self.wrench.get_frame_profiles(); if frame_count >= self.warmup_frames {
cpu_frame_profiles.extend(cpu_profiles);
gpu_frame_profiles.extend(gpu_profiles);
}
frame_count += 1;
}
// Ensure the draw calls match in every sample. let draw_calls = cpu_frame_profiles[0].draw_calls; let draw_calls_same =
cpu_frame_profiles
.iter()
.all(|s| s.draw_calls == draw_calls);
// this can be normal in cases where some elements are cached (eg. linear // gradients), but print a warning in case it's not (which could make the // benchmark produce unexpected results). if !draw_calls_same {
println!("Warning: not every frame has the same number of draw calls");
}
let composite_time_ns = extract_sample(&mut cpu_frame_profiles, |a| a.composite_time_ns); let paint_time_ns = extract_sample(&mut gpu_frame_profiles, |a| a.paint_time_ns); let backend_time_ns = extract_sample(&mut cpu_frame_profiles, |a| a.backend_time_ns);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.