Update the benchmark
This commit is contained in:
parent
94406a1d62
commit
b7e9763e5a
|
@ -28,9 +28,13 @@ use pathfinder::rasterizer::{Rasterizer, RasterizerOptions};
|
|||
use std::env;
|
||||
use std::os::raw::c_void;
|
||||
|
||||
const ATLAS_SIZE: u32 = 2048;
|
||||
const WIDTH: u32 = 512;
|
||||
const HEIGHT: u32 = 384;
|
||||
|
||||
const MIN_TIME_PER_SIZE: u64 = 300_000_000;
|
||||
const MAX_TIME_PER_SIZE: u64 = 3_000_000_000;
|
||||
|
||||
fn main() {
|
||||
let mut glfw = glfw::init(glfw::LOG_ERRORS).unwrap();
|
||||
glfw.window_hint(WindowHint::ContextVersion(3, 3));
|
||||
|
@ -41,7 +45,7 @@ fn main() {
|
|||
let (mut window, _events) = context.expect("Couldn't create a window!");
|
||||
window.make_current();
|
||||
gl::load_with(|symbol| window.get_proc_address(symbol) as *const c_void);
|
||||
let (device_pixel_width, device_pixel_height) = window.get_framebuffer_size();
|
||||
let (device_pixel_width, _) = window.get_framebuffer_size();
|
||||
|
||||
let instance = Instance::new().unwrap();
|
||||
let device = instance.create_device().unwrap();
|
||||
|
@ -54,11 +58,17 @@ fn main() {
|
|||
// FIXME(pcwalton)
|
||||
let shelf_height = point_size * 2;
|
||||
|
||||
let mut glyph_buffer_builder = GlyphBufferBuilder::new();
|
||||
let mut batch_builder = BatchBuilder::new(device_pixel_width as GLuint, shelf_height);
|
||||
|
||||
let file = Mmap::open_path(env::args().nth(1).unwrap(), Protection::Read).unwrap();
|
||||
let mut glyph_count = 0;
|
||||
|
||||
let mut results = vec![];
|
||||
let start = time::precise_time_ns();
|
||||
let mut last_time = start;
|
||||
let (mut glyph_buffer_builder, mut batch_builder, mut glyph_count);
|
||||
let (mut glyph_buffers, mut batch);
|
||||
loop {
|
||||
glyph_buffer_builder = GlyphBufferBuilder::new();
|
||||
batch_builder = BatchBuilder::new(device_pixel_width as GLuint, shelf_height);
|
||||
glyph_count = 0;
|
||||
unsafe {
|
||||
let font = Font::new(file.as_slice()).unwrap();
|
||||
let codepoint_ranges = [CodepointRange::new(' ' as u32, '~' as u32)];
|
||||
|
@ -73,12 +83,25 @@ fn main() {
|
|||
.unwrap();
|
||||
glyph_count += 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let glyph_buffers = glyph_buffer_builder.create_buffers().unwrap();
|
||||
let batch = batch_builder.create_batch(&glyph_buffer_builder).unwrap();
|
||||
glyph_buffers = glyph_buffer_builder.create_buffers().unwrap();
|
||||
batch = batch_builder.create_batch(&glyph_buffer_builder).unwrap();
|
||||
|
||||
let atlas_size = Size2D::new(device_pixel_width as GLuint, device_pixel_height as GLuint);
|
||||
let end = time::precise_time_ns();
|
||||
results.push((end - last_time) as f64);
|
||||
if end - start > MAX_TIME_PER_SIZE {
|
||||
break
|
||||
}
|
||||
last_time = end
|
||||
}
|
||||
|
||||
stats::winsorize(&mut results, 5.0);
|
||||
let time_per_glyph = results.mean() / 1_000.0 / glyph_count as f64;
|
||||
println!("cpu,{}", time_per_glyph);
|
||||
|
||||
let atlas_size = Size2D::new(ATLAS_SIZE, ATLAS_SIZE);
|
||||
let coverage_buffer = CoverageBuffer::new(&rasterizer.device, &atlas_size).unwrap();
|
||||
|
||||
let texture = rasterizer.device
|
||||
|
@ -107,8 +130,8 @@ fn main() {
|
|||
results.push(time_per_glyph);
|
||||
|
||||
let now = time::precise_time_ns();
|
||||
if (now - start_time > 300_000_000 && results.median_abs_dev_pct() < 1.0) ||
|
||||
now - start_time > 3_000_000_000 {
|
||||
if (now - start_time > MIN_TIME_PER_SIZE && results.median_abs_dev_pct() < 1.0) ||
|
||||
now - start_time > MAX_TIME_PER_SIZE {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ fn main() {
|
|||
}
|
||||
|
||||
let glyph_buffers = glyph_buffer_builder.create_buffers().unwrap();
|
||||
let batch = batch_builder.create_atlas(&glyph_buffer_builder).unwrap();
|
||||
let batch = batch_builder.create_batch(buffer_builder).unwrap();
|
||||
|
||||
let atlas_size = Size2D::new(device_pixel_width as GLuint, device_pixel_height as GLuint);
|
||||
let coverage_buffer = CoverageBuffer::new(&rasterizer.device, &atlas_size).unwrap();
|
||||
|
@ -75,11 +75,11 @@ fn main() {
|
|||
.unwrap();
|
||||
|
||||
rasterizer.draw_atlas(&Rect::new(Point2D::new(0, 0), atlas_size),
|
||||
SHELF_HEIGHT,
|
||||
&batch_builder.atlas,
|
||||
&glyph_buffers,
|
||||
&batch,
|
||||
&coverage_buffer,
|
||||
&texture).unwrap().wait().unwrap();
|
||||
&texture).unwrap();
|
||||
|
||||
let draw_context = lord_drawquaad::Context::new();
|
||||
|
||||
|
|
|
@ -162,11 +162,11 @@ impl GlyphDescriptor {
|
|||
#[derive(Copy, Clone, Debug)]
|
||||
#[repr(C)]
|
||||
pub struct Vertex {
|
||||
x: i16,
|
||||
y: i16,
|
||||
pub x: i16,
|
||||
pub y: i16,
|
||||
/// TODO(pcwalton): Try omitting this and binary search the glyph descriptors in the vertex
|
||||
/// shader. Might or might not help.
|
||||
glyph_index: u16,
|
||||
pub glyph_index: u16,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
|
Loading…
Reference in New Issue