bench: Remove usage of fmt!
This commit is contained in:
parent
02054ac8a1
commit
73c6c9109f
@ -128,7 +128,7 @@ fn write_header(header: &str) {
|
||||
}
|
||||
|
||||
fn write_row(label: &str, value: float) {
|
||||
io::stdout().write_str(fmt!("%30s %f s\n", label, value));
|
||||
io::stdout().write_str(format!("{:30s} {} s\n", label, value));
|
||||
}
|
||||
|
||||
fn write_results(label: &str, results: &Results) {
|
||||
|
@ -133,7 +133,7 @@ fn is_utf8_ascii() {
|
||||
for _ in range(0u, 20000) {
|
||||
v.push('b' as u8);
|
||||
if !str::is_utf8(v) {
|
||||
fail!("is_utf8 failed");
|
||||
fail2!("is_utf8 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ fn is_utf8_multibyte() {
|
||||
for _ in range(0u, 5000) {
|
||||
v.push_all(s.as_bytes());
|
||||
if !str::is_utf8(v) {
|
||||
fail!("is_utf8 failed");
|
||||
fail2!("is_utf8 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ fn main() {
|
||||
|
||||
for i in range(0u, n) {
|
||||
let x = i.to_str();
|
||||
info!(x);
|
||||
info2!("{}", x);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ fn server(requests: &Port<request>, responses: &Chan<uint>) {
|
||||
match requests.try_recv() {
|
||||
Some(get_count) => { responses.send(count.clone()); }
|
||||
Some(bytes(b)) => {
|
||||
//error!("server: received %? bytes", b);
|
||||
//error2!("server: received {:?} bytes", b);
|
||||
count += b;
|
||||
}
|
||||
None => { done = true; }
|
||||
@ -50,7 +50,7 @@ fn server(requests: &Port<request>, responses: &Chan<uint>) {
|
||||
}
|
||||
}
|
||||
responses.send(count);
|
||||
//error!("server exiting");
|
||||
//error2!("server exiting");
|
||||
}
|
||||
|
||||
fn run(args: &[~str]) {
|
||||
@ -70,10 +70,10 @@ fn run(args: &[~str]) {
|
||||
builder.future_result(|r| worker_results.push(r));
|
||||
do builder.spawn {
|
||||
for _ in range(0u, size / workers) {
|
||||
//error!("worker %?: sending %? bytes", i, num_bytes);
|
||||
//error2!("worker {:?}: sending {:?} bytes", i, num_bytes);
|
||||
to_child.send(bytes(num_bytes));
|
||||
}
|
||||
//error!("worker %? exiting", i);
|
||||
//error2!("worker {:?} exiting", i);
|
||||
}
|
||||
}
|
||||
do task::spawn || {
|
||||
@ -84,16 +84,16 @@ fn run(args: &[~str]) {
|
||||
r.recv();
|
||||
}
|
||||
|
||||
//error!("sending stop message");
|
||||
//error2!("sending stop message");
|
||||
to_child.send(stop);
|
||||
move_out(to_child);
|
||||
let result = from_child.recv();
|
||||
let end = extra::time::precise_time_s();
|
||||
let elapsed = end - start;
|
||||
io::stdout().write_str(fmt!("Count is %?\n", result));
|
||||
io::stdout().write_str(fmt!("Test took %? seconds\n", elapsed));
|
||||
io::stdout().write_str(format!("Count is {:?}\n", result));
|
||||
io::stdout().write_str(format!("Test took {:?} seconds\n", elapsed));
|
||||
let thruput = ((size / workers * workers) as float) / (elapsed as float);
|
||||
io::stdout().write_str(fmt!("Throughput=%f per sec\n", thruput));
|
||||
io::stdout().write_str(format!("Throughput={} per sec\n", thruput));
|
||||
assert_eq!(result, num_bytes * size);
|
||||
}
|
||||
|
||||
@ -107,6 +107,6 @@ fn main() {
|
||||
args.clone()
|
||||
};
|
||||
|
||||
info!("%?", args);
|
||||
info2!("{:?}", args);
|
||||
run(args);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ fn server(requests: &Port<request>, responses: &Chan<uint>) {
|
||||
match requests.try_recv() {
|
||||
Some(get_count) => { responses.send(count.clone()); }
|
||||
Some(bytes(b)) => {
|
||||
//error!("server: received %? bytes", b);
|
||||
//error2!("server: received {:?} bytes", b);
|
||||
count += b;
|
||||
}
|
||||
None => { done = true; }
|
||||
@ -45,7 +45,7 @@ fn server(requests: &Port<request>, responses: &Chan<uint>) {
|
||||
}
|
||||
}
|
||||
responses.send(count);
|
||||
//error!("server exiting");
|
||||
//error2!("server exiting");
|
||||
}
|
||||
|
||||
fn run(args: &[~str]) {
|
||||
@ -64,10 +64,10 @@ fn run(args: &[~str]) {
|
||||
builder.future_result(|r| worker_results.push(r));
|
||||
do builder.spawn {
|
||||
for _ in range(0u, size / workers) {
|
||||
//error!("worker %?: sending %? bytes", i, num_bytes);
|
||||
//error2!("worker {:?}: sending {:?} bytes", i, num_bytes);
|
||||
to_child.send(bytes(num_bytes));
|
||||
}
|
||||
//error!("worker %? exiting", i);
|
||||
//error2!("worker {:?} exiting", i);
|
||||
};
|
||||
}
|
||||
do task::spawn || {
|
||||
@ -78,16 +78,16 @@ fn run(args: &[~str]) {
|
||||
r.recv();
|
||||
}
|
||||
|
||||
//error!("sending stop message");
|
||||
//error2!("sending stop message");
|
||||
to_child.send(stop);
|
||||
move_out(to_child);
|
||||
let result = from_child.recv();
|
||||
let end = extra::time::precise_time_s();
|
||||
let elapsed = end - start;
|
||||
io::stdout().write_str(fmt!("Count is %?\n", result));
|
||||
io::stdout().write_str(fmt!("Test took %? seconds\n", elapsed));
|
||||
io::stdout().write_str(format!("Count is {:?}\n", result));
|
||||
io::stdout().write_str(format!("Test took {:?} seconds\n", elapsed));
|
||||
let thruput = ((size / workers * workers) as float) / (elapsed as float);
|
||||
io::stdout().write_str(fmt!("Throughput=%f per sec\n", thruput));
|
||||
io::stdout().write_str(format!("Throughput={} per sec\n", thruput));
|
||||
assert_eq!(result, num_bytes * size);
|
||||
}
|
||||
|
||||
@ -101,6 +101,6 @@ fn main() {
|
||||
args.clone()
|
||||
};
|
||||
|
||||
info!("%?", args);
|
||||
info2!("{:?}", args);
|
||||
run(args);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ fn show_digit(nn: uint) -> ~str {
|
||||
7 => {~"seven"}
|
||||
8 => {~"eight"}
|
||||
9 => {~"nine"}
|
||||
_ => {fail!("expected digits from 0 to 9...")}
|
||||
_ => {fail2!("expected digits from 0 to 9...")}
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,8 +129,8 @@ fn creature(
|
||||
}
|
||||
option::None => {
|
||||
// log creatures met and evil clones of self
|
||||
let report = fmt!("%u %s",
|
||||
creatures_met, show_number(evil_clones_met));
|
||||
let report = format!("{} {}",
|
||||
creatures_met, show_number(evil_clones_met));
|
||||
to_rendezvous_log.send(report);
|
||||
break;
|
||||
}
|
||||
|
@ -75,7 +75,8 @@ fn sortKV<TT:Clone + Ord, UU:Clone + Ord>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
|
||||
let b = str::raw::from_utf8(k);
|
||||
// FIXME: #4318 Instead of to_ascii and to_str_ascii, could use
|
||||
// to_ascii_move and to_str_move to not do a unnecessary copy.
|
||||
buffer.push_str(fmt!("%s %0.3f\n", b.to_ascii().to_upper().to_str_ascii(), v));
|
||||
buffer.push_str(format!("{} {:0.3f}\n",
|
||||
b.to_ascii().to_upper().to_str_ascii(), v));
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,11 +143,11 @@ fn make_sequence_processor(sz: uint,
|
||||
let buffer = match sz {
|
||||
1u => { sort_and_fmt(&freqs, total) }
|
||||
2u => { sort_and_fmt(&freqs, total) }
|
||||
3u => { fmt!("%u\t%s", find(&freqs, ~"GGT"), "GGT") }
|
||||
4u => { fmt!("%u\t%s", find(&freqs, ~"GGTA"), "GGTA") }
|
||||
6u => { fmt!("%u\t%s", find(&freqs, ~"GGTATT"), "GGTATT") }
|
||||
12u => { fmt!("%u\t%s", find(&freqs, ~"GGTATTTTAATT"), "GGTATTTTAATT") }
|
||||
18u => { fmt!("%u\t%s", find(&freqs, ~"GGTATTTTAATTTATAGT"), "GGTATTTTAATTTATAGT") }
|
||||
3u => { format!("{}\t{}", find(&freqs, ~"GGT"), "GGT") }
|
||||
4u => { format!("{}\t{}", find(&freqs, ~"GGTA"), "GGTA") }
|
||||
6u => { format!("{}\t{}", find(&freqs, ~"GGTATT"), "GGTATT") }
|
||||
12u => { format!("{}\t{}", find(&freqs, ~"GGTATTTTAATT"), "GGTATTTTAATT") }
|
||||
18u => { format!("{}\t{}", find(&freqs, ~"GGTATTTTAATTTATAGT"), "GGTATTTTAATTTATAGT") }
|
||||
_ => { ~"" }
|
||||
};
|
||||
|
||||
|
@ -66,7 +66,7 @@ fn parse_opts(argv: ~[~str]) -> Config {
|
||||
Ok(ref m) => {
|
||||
return Config {stress: m.opt_present("stress")}
|
||||
}
|
||||
Err(_) => { fail!(); }
|
||||
Err(_) => { fail2!(); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ fn stress_task(id: int) {
|
||||
let n = 15;
|
||||
assert_eq!(fib(n), fib(n));
|
||||
i += 1;
|
||||
error!("%d: Completed %d iterations", id, i);
|
||||
error2!("{}: Completed {} iterations", id, i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,8 +123,8 @@ fn main() {
|
||||
|
||||
let elapsed = stop - start;
|
||||
|
||||
out.write_line(fmt!("%d\t%d\t%s", n, fibn,
|
||||
elapsed.to_str()));
|
||||
out.write_line(format!("{}\t{}\t{}", n, fibn,
|
||||
elapsed.to_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ fn main() {
|
||||
|
||||
let maxf = max as float;
|
||||
|
||||
io::stdout().write_str(fmt!("insert(): %? seconds\n", checkf));
|
||||
io::stdout().write_str(fmt!(" : %f op/sec\n", maxf/checkf));
|
||||
io::stdout().write_str(fmt!("get() : %? seconds\n", appendf));
|
||||
io::stdout().write_str(fmt!(" : %f op/sec\n", maxf/appendf));
|
||||
io::stdout().write_str(format!("insert(): {:?} seconds\n", checkf));
|
||||
io::stdout().write_str(format!(" : {} op/sec\n", maxf/checkf));
|
||||
io::stdout().write_str(format!("get() : {:?} seconds\n", appendf));
|
||||
io::stdout().write_str(format!(" : {} op/sec\n", maxf/appendf));
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ pub fn read(reader: @io::Reader) -> Sudoku {
|
||||
g[row][col] = from_str::<uint>(comps[2]).unwrap() as u8;
|
||||
}
|
||||
else {
|
||||
fail!("Invalid sudoku file");
|
||||
fail2!("Invalid sudoku file");
|
||||
}
|
||||
}
|
||||
return Sudoku::new(g)
|
||||
@ -87,9 +87,9 @@ pub fn read(reader: @io::Reader) -> Sudoku {
|
||||
|
||||
pub fn write(&self, writer: @io::Writer) {
|
||||
for row in range(0u8, 9u8) {
|
||||
writer.write_str(fmt!("%u", self.grid[row][0] as uint));
|
||||
writer.write_str(format!("{}", self.grid[row][0] as uint));
|
||||
for col in range(1u8, 9u8) {
|
||||
writer.write_str(fmt!(" %u", self.grid[row][col] as uint));
|
||||
writer.write_str(format!(" {}", self.grid[row][col] as uint));
|
||||
}
|
||||
writer.write_char('\n');
|
||||
}
|
||||
@ -117,7 +117,7 @@ pub fn solve(&mut self) {
|
||||
ptr = ptr + 1u;
|
||||
} else {
|
||||
// no: redo this field aft recoloring pred; unless there is none
|
||||
if ptr == 0u { fail!("No solution found for this sudoku"); }
|
||||
if ptr == 0u { fail2!("No solution found for this sudoku"); }
|
||||
ptr = ptr - 1u;
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ fn main() {
|
||||
|
||||
fn run(repeat: int, depth: int) {
|
||||
for _ in range(0, repeat) {
|
||||
info!("starting %.4f", precise_time_s());
|
||||
info2!("starting {:.4f}", precise_time_s());
|
||||
do task::try {
|
||||
recurse_or_fail(depth, None)
|
||||
};
|
||||
info!("stopping %.4f", precise_time_s());
|
||||
info2!("stopping {:.4f}", precise_time_s());
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ fn r(l: @nillist) -> r {
|
||||
|
||||
fn recurse_or_fail(depth: int, st: Option<State>) {
|
||||
if depth == 0 {
|
||||
info!("unwinding %.4f", precise_time_s());
|
||||
fail!();
|
||||
info2!("unwinding {:.4f}", precise_time_s());
|
||||
fail2!();
|
||||
} else {
|
||||
let depth = depth - 1;
|
||||
|
||||
|
@ -54,6 +54,6 @@ fn main() {
|
||||
let (p,c) = comm::stream();
|
||||
child_generation(from_str::<uint>(args[1]).unwrap(), c);
|
||||
if p.try_recv().is_none() {
|
||||
fail!("it happened when we slumbered");
|
||||
fail2!("it happened when we slumbered");
|
||||
}
|
||||
}
|
||||
|
@ -43,13 +43,13 @@ fn grandchild_group(num_tasks: uint) {
|
||||
p.recv(); // block forever
|
||||
}
|
||||
}
|
||||
error!("Grandchild group getting started");
|
||||
error2!("Grandchild group getting started");
|
||||
for _ in range(0, num_tasks) {
|
||||
// Make sure all above children are fully spawned; i.e., enlisted in
|
||||
// their ancestor groups.
|
||||
po.recv();
|
||||
}
|
||||
error!("Grandchild group ready to go.");
|
||||
error2!("Grandchild group ready to go.");
|
||||
// Master grandchild task exits early.
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ fn spawn_supervised_blocking(myname: &str, f: ~fn()) {
|
||||
builder.future_result(|r| res = Some(r));
|
||||
builder.supervised();
|
||||
builder.spawn(f);
|
||||
error!("%s group waiting", myname);
|
||||
error2!("{} group waiting", myname);
|
||||
let x = res.unwrap().recv();
|
||||
assert_eq!(x, task::Success);
|
||||
}
|
||||
@ -85,11 +85,11 @@ fn main() {
|
||||
grandchild_group(num_tasks);
|
||||
}
|
||||
// When grandchild group is ready to go, make the middle group exit.
|
||||
error!("Middle group wakes up and exits");
|
||||
error2!("Middle group wakes up and exits");
|
||||
}
|
||||
// Grandparent group waits for middle group to be gone, then fails
|
||||
error!("Grandparent group wakes up and fails");
|
||||
fail!();
|
||||
error2!("Grandparent group wakes up and fails");
|
||||
fail2!();
|
||||
};
|
||||
assert!(x.is_err());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user