Remove code to measure effect of varying numbers of threads.

task-queue
Jim Blandy 5 years ago
parent be390df13d
commit 791d5c403b

@ -172,46 +172,38 @@ fn main() {
let mut pixels = vec![0; bounds.0 * bounds.1];
for threads in [1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
20, 30, 40, 50, 60, 70, 80, 90,
//100, 200, 300, 400, 500, 600, 700, 800, 900, 1000
].iter() {
let band_rows = bounds.1 / 400;
let dt = measure_elapsed_time(|| {
let bands = Mutex::new(pixels.chunks_mut(band_rows * bounds.0).enumerate());
crossbeam::scope(|scope| {
for i in 0..*threads {
scope.spawn(|| {
let mut count = 0;
loop {
match {
let mut guard = bands.lock().unwrap();
guard.next()
}
{
None => { return; }
Some((i, band)) => {
count += 1;
let top = band_rows * i;
let height = band.len() / bounds.0;
let band_bounds = (bounds.0, height);
let band_upper_left = pixel_to_point(bounds, (0, top),
upper_left, lower_right);
let band_lower_right = pixel_to_point(bounds, (bounds.0, top + height),
upper_left, lower_right);
render(band, band_bounds, band_upper_left, band_lower_right);
}
let threads = 8;
let band_rows = bounds.1 / threads + 1;
{
let bands = Mutex::new(pixels.chunks_mut(band_rows * bounds.0).enumerate());
crossbeam::scope(|scope| {
for i in 0..threads {
scope.spawn(|| {
let mut count = 0;
loop {
match {
let mut guard = bands.lock().unwrap();
guard.next()
}
{
None => { return; }
Some((i, band)) => {
count += 1;
let top = band_rows * i;
let height = band.len() / bounds.0;
let band_bounds = (bounds.0, height);
let band_upper_left = pixel_to_point(bounds, (0, top),
upper_left, lower_right);
let band_lower_right = pixel_to_point(bounds, (bounds.0, top + height),
upper_left, lower_right);
render(band, band_bounds, band_upper_left, band_lower_right);
}
}
});
}
});
}
});
}
});
println!("{:4} {:.3}",
threads,
dt.as_secs() as f64 + dt.subsec_nanos() as f64 * 1e-9);
}
write_image(&args[1], &pixels[..], bounds).expect("error writing PNG file");

Loading…
Cancel
Save