mirror of https://github.com/rust-lang/rust.git
Merge pull request #20718 from tshepang/bench-fix-some-warnings
bench: fix a few compiler warnings Reviewed-by: alexcrichton
This commit is contained in:
commit
e72ad98e46
|
@ -14,7 +14,6 @@ use std::collections::{BTreeMap, HashMap, HashSet};
|
|||
use std::os;
|
||||
use std::rand::{Rng, IsaacRng, SeedableRng};
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
fn timed<F>(label: &str, f: F) where F: FnMut() {
|
||||
println!(" {}: {}", label, Duration::span(f));
|
||||
|
|
|
@ -22,7 +22,6 @@ use std::collections::hash_map::Hasher;
|
|||
use std::hash::Hash;
|
||||
use std::os;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
struct Results {
|
||||
sequential_ints: Duration,
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::uint;
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
|
|
|
@ -22,7 +22,6 @@ use std::sync::mpsc::{channel, Sender, Receiver};
|
|||
use std::os;
|
||||
use std::thread::Thread;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
fn move_out<T>(_x: T) {}
|
||||
|
||||
|
|
|
@ -18,9 +18,6 @@ use std::sync::mpsc::{channel, Sender, Receiver};
|
|||
use std::os;
|
||||
use std::thread::Thread;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
fn move_out<T>(_x: T) {}
|
||||
|
||||
enum request {
|
||||
get_count,
|
||||
|
@ -42,7 +39,7 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
|
|||
_ => { }
|
||||
}
|
||||
}
|
||||
responses.send(count);
|
||||
responses.send(count).unwrap();
|
||||
//println!("server exiting");
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
use std::os;
|
||||
use std::sync::{Arc, Future, Mutex, Condvar};
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
// A poor man's pipe.
|
||||
type pipe = Arc<(Mutex<Vec<uint>>, Condvar)>;
|
||||
|
@ -76,7 +75,7 @@ fn main() {
|
|||
let num_tasks = args[1].parse::<uint>().unwrap();
|
||||
let msg_per_task = args[2].parse::<uint>().unwrap();
|
||||
|
||||
let (mut num_chan, num_port) = init();
|
||||
let (num_chan, num_port) = init();
|
||||
|
||||
let mut p = Some((num_chan, num_port));
|
||||
let dur = Duration::span(|| {
|
||||
|
|
|
@ -11,23 +11,22 @@
|
|||
use std::sync::mpsc::channel;
|
||||
use std::os;
|
||||
use std::thread::Thread;
|
||||
use std::uint;
|
||||
|
||||
// A simple implementation of parfib. One subtree is found in a new
|
||||
// task and communicated over a oneshot pipe, the other is found
|
||||
// locally. There is no sequential-mode threshold.
|
||||
|
||||
fn parfib(n: uint) -> uint {
|
||||
if(n == 0 || n == 1) {
|
||||
if n == 0 || n == 1 {
|
||||
return 1;
|
||||
}
|
||||
|
||||
let (tx, rx) = channel();
|
||||
Thread::spawn(move|| {
|
||||
tx.send(parfib(n-1));
|
||||
tx.send(parfib(n-1)).unwrap();
|
||||
});
|
||||
let m2 = parfib(n-2);
|
||||
return (rx.recv().unwrap() + m2);
|
||||
return rx.recv().unwrap() + m2;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -92,7 +92,7 @@ fn main() {
|
|||
let long_lived_arena = TypedArena::new();
|
||||
let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth);
|
||||
|
||||
let mut messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
|
||||
let messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
|
||||
use std::num::Int;
|
||||
let iterations = 2i.pow((max_depth - depth + min_depth) as uint);
|
||||
Thread::scoped(move|| {
|
||||
|
|
|
@ -182,7 +182,7 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
|
|||
let (to_rendezvous_log, from_creatures_log) = channel::<String>();
|
||||
|
||||
// these channels will allow us to talk to each creature by 'name'/index
|
||||
let mut to_creature: Vec<Sender<CreatureInfo>> =
|
||||
let to_creature: Vec<Sender<CreatureInfo>> =
|
||||
set.iter().enumerate().map(|(ii, &col)| {
|
||||
// create each creature as a listener with a port, and
|
||||
// give us a channel to talk to each
|
||||
|
|
|
@ -128,7 +128,7 @@ impl Perm {
|
|||
}
|
||||
|
||||
|
||||
fn reverse(tperm: &mut [i32], mut k: uint) {
|
||||
fn reverse(tperm: &mut [i32], k: uint) {
|
||||
tperm.slice_to_mut(k).reverse()
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
|||
let mut futures = vec![];
|
||||
let k = perm.max() / N;
|
||||
|
||||
for (i, j) in range(0, N).zip(iter::count(0, k)) {
|
||||
for (_, j) in range(0, N).zip(iter::count(0, k)) {
|
||||
let max = cmp::min(j+k, perm.max());
|
||||
|
||||
futures.push(Thread::scoped(move|| {
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#![feature(box_syntax)]
|
||||
|
||||
use std::ascii::OwnedAsciiExt;
|
||||
use std::iter::repeat;
|
||||
use std::slice;
|
||||
use std::sync::Arc;
|
||||
use std::thread::Thread;
|
||||
|
|
|
@ -202,6 +202,6 @@ fn shift_mut_ref<'a, T>(r: &mut &'a mut [T]) -> Option<&'a mut T> {
|
|||
raw.data = raw.data.offset(1);
|
||||
raw.len -= 1;
|
||||
*r = mem::transmute(raw);
|
||||
Some(unsafe { &mut *ret })
|
||||
Some({ &mut *ret })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ unsafe impl<T: 'static> Send for Racy<T> {}
|
|||
|
||||
/// Executes a closure in parallel over the given iterator over mutable slice.
|
||||
/// The closure `f` is run in parallel with an element of `iter`.
|
||||
fn parallel<'a, I, T, F>(mut iter: I, f: F)
|
||||
fn parallel<'a, I, T, F>(iter: I, f: F)
|
||||
where T: 'a+Send + Sync,
|
||||
I: Iterator<Item=&'a mut [T]>,
|
||||
F: Fn(&mut [T]) + Sync {
|
||||
|
|
|
@ -43,7 +43,7 @@ use std::thread::Thread;
|
|||
|
||||
fn start(n_tasks: int, token: int) {
|
||||
let (tx, mut rx) = channel();
|
||||
tx.send(token);
|
||||
tx.send(token).unwrap();
|
||||
for i in range(2, n_tasks + 1) {
|
||||
let (tx, next_rx) = channel();
|
||||
Thread::spawn(move|| roundtrip(i, tx, rx));
|
||||
|
@ -58,7 +58,7 @@ fn roundtrip(id: int, tx: Sender<int>, rx: Receiver<int>) {
|
|||
println!("{}", id);
|
||||
break;
|
||||
}
|
||||
tx.send(token - 1);
|
||||
tx.send(token - 1).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
use std::collections::VecMap;
|
||||
use std::os;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
fn append_sequential(min: uint, max: uint, map: &mut VecMap<uint>) {
|
||||
for i in range(min, max) {
|
||||
|
|
|
@ -55,18 +55,6 @@ impl Sudoku {
|
|||
return Sudoku::new(g)
|
||||
}
|
||||
|
||||
pub fn equal(&self, other: &Sudoku) -> bool {
|
||||
for row in range(0u8, 9u8) {
|
||||
for col in range(0u8, 9u8) {
|
||||
if self.grid[row as uint][col as uint] !=
|
||||
other.grid[row as uint][col as uint] {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn read(mut reader: &mut BufferedReader<StdReader>) -> Sudoku {
|
||||
/* assert first line is exactly "9,9" */
|
||||
assert!(reader.read_line().unwrap() == "9,9".to_string());
|
||||
|
@ -184,7 +172,7 @@ impl Colors {
|
|||
fn next(&self) -> u8 {
|
||||
let Colors(c) = *self;
|
||||
let val = c & HEADS;
|
||||
if (0u16 == val) {
|
||||
if 0u16 == val {
|
||||
return 0u8;
|
||||
} else {
|
||||
return val.trailing_zeros() as u8
|
||||
|
|
|
@ -19,10 +19,6 @@ enum List<T> {
|
|||
Nil, Cons(T, Box<List<T>>)
|
||||
}
|
||||
|
||||
enum UniqueList {
|
||||
ULNil, ULCons(Box<UniqueList>)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (repeat, depth) = if os::getenv("RUST_BENCH").is_some() {
|
||||
(50, 1000)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::os;
|
||||
use std::thread::Thread;
|
||||
use std::uint;
|
||||
|
||||
fn child_generation(gens_left: uint, tx: Sender<()>) {
|
||||
// This used to be O(n^2) in the number of generations that ever existed.
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::uint;
|
||||
use std::thread::Thread;
|
||||
|
||||
fn f(n: uint) {
|
||||
|
|
Loading…
Reference in New Issue