From 73c6c9109fb334edf159ad08f67cc2e66c7035a5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 29 Sep 2013 23:13:47 -0700 Subject: [PATCH] bench: Remove usage of fmt! --- src/test/bench/core-set.rs | 2 +- src/test/bench/core-std.rs | 4 ++-- src/test/bench/core-uint-to-str.rs | 2 +- src/test/bench/msgsend-pipes-shared.rs | 18 +++++++++--------- src/test/bench/msgsend-pipes.rs | 18 +++++++++--------- src/test/bench/shootout-chameneos-redux.rs | 6 +++--- src/test/bench/shootout-k-nucleotide-pipes.rs | 13 +++++++------ src/test/bench/shootout-pfib.rs | 8 ++++---- src/test/bench/std-smallintmap.rs | 8 ++++---- src/test/bench/sudoku.rs | 8 ++++---- src/test/bench/task-perf-alloc-unwind.rs | 8 ++++---- src/test/bench/task-perf-jargon-metal-smoke.rs | 2 +- src/test/bench/task-perf-linked-failure.rs | 12 ++++++------ 13 files changed, 55 insertions(+), 54 deletions(-) diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index ead1128e994..a4c07371f67 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -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) { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 82c1b196c12..fa2b74ef44c 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -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"); } } } diff --git a/src/test/bench/core-uint-to-str.rs b/src/test/bench/core-uint-to-str.rs index 6b1319aa0c9..ef6610cd93a 100644 --- a/src/test/bench/core-uint-to-str.rs +++ b/src/test/bench/core-uint-to-str.rs @@ -25,6 +25,6 @@ fn main() { for i in range(0u, n) { let x = i.to_str(); - info!(x); + info2!("{}", x); } } diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index af15acc1535..ba7682f5bbd 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -42,7 +42,7 @@ fn server(requests: &Port, responses: &Chan) { 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, responses: &Chan) { } } 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); } diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 3b095650b7e..1db73f9a95d 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -37,7 +37,7 @@ fn server(requests: &Port, responses: &Chan) { 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, responses: &Chan) { } } 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); } diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index e4f395e5eca..c3296cbff9b 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -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; } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index f0bf7fc7a6b..4c246bbe3f7 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -75,7 +75,8 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str { 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") } _ => { ~"" } }; diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 0896682b322..5a1f7350010 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -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())); } } } diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index 6940c97d76e..2e812ba2d09 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -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)); } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 2c5b434a476..91d9c9656af 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -79,7 +79,7 @@ impl Sudoku { g[row][col] = from_str::(comps[2]).unwrap() as u8; } else { - fail!("Invalid sudoku file"); + fail2!("Invalid sudoku file"); } } return Sudoku::new(g) @@ -87,9 +87,9 @@ impl 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 @@ impl Sudoku { 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; } } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 991c102e9f0..639cbd05cbf 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -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) { if depth == 0 { - info!("unwinding %.4f", precise_time_s()); - fail!(); + info2!("unwinding {:.4f}", precise_time_s()); + fail2!(); } else { let depth = depth - 1; diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 0827f7d3447..ac028686f08 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -54,6 +54,6 @@ fn main() { let (p,c) = comm::stream(); child_generation(from_str::(args[1]).unwrap(), c); if p.try_recv().is_none() { - fail!("it happened when we slumbered"); + fail2!("it happened when we slumbered"); } } diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index 5aeba3f415d..b029d9e4fc8 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -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()); }