]> git.lizzy.rs Git - rust.git/commitdiff
testsuite: De-record most bench tests
authorTim Chevalier <chevalier@alum.wellesley.edu>
Tue, 29 Jan 2013 02:55:44 +0000 (18:55 -0800)
committerTim Chevalier <chevalier@alum.wellesley.edu>
Tue, 29 Jan 2013 03:41:56 +0000 (19:41 -0800)
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-nbody.rs
src/test/bench/shootout-pfib.rs
src/test/bench/task-perf-alloc-unwind.rs

index c842402c70b49b0449fad4f3fc004d1979592603..5853e6e0e877dd8b9591d76df6ccff47515dc47a 100644 (file)
@@ -27,7 +27,10 @@ fn print_complements() {
 
 enum color { Red, Yellow, Blue }
 
-type creature_info = { name: uint, color: color };
+struct CreatureInfo {
+    name: uint,
+    color: color
+}
 
 fn show_color(cc: color) -> ~str {
     match (cc) {
@@ -95,8 +98,8 @@ fn transform(aa: color, bb: color) -> color {
 fn creature(
     name: uint,
     color: color,
-    from_rendezvous: oldcomm::Port<Option<creature_info>>,
-    to_rendezvous: oldcomm::Chan<creature_info>,
+    from_rendezvous: oldcomm::Port<Option<CreatureInfo>>,
+    to_rendezvous: oldcomm::Chan<CreatureInfo>,
     to_rendezvous_log: oldcomm::Chan<~str>
 ) {
     let mut color = color;
@@ -105,7 +108,7 @@ fn creature(
 
     loop {
         // ask for a pairing
-        oldcomm::send(to_rendezvous, {name: name, color: color});
+        oldcomm::send(to_rendezvous, CreatureInfo {name: name, color: color});
         let resp = oldcomm::recv(from_rendezvous);
 
         // log and change, or print and quit
@@ -145,7 +148,7 @@ pub fn spawn_listener<A: Owned>(+f: fn~(oldcomm::Port<A>)) -> oldcomm::Chan<A> {
     }
 
     // these ports will allow us to hear from the creatures
-    let from_creatures:     oldcomm::Port<creature_info> = oldcomm::Port();
+    let from_creatures:     oldcomm::Port<CreatureInfo> = oldcomm::Port();
     let from_creatures_log: oldcomm::Port<~str> = oldcomm::Port();
 
     // these channels will be passed to the creatures so they can talk to us
@@ -153,7 +156,7 @@ pub fn spawn_listener<A: Owned>(+f: fn~(oldcomm::Port<A>)) -> oldcomm::Chan<A> {
     let to_rendezvous_log = oldcomm::Chan(&from_creatures_log);
 
     // these channels will allow us to talk to each creature by 'name'/index
-    let to_creature: ~[oldcomm::Chan<Option<creature_info>>] =
+    let to_creature: ~[oldcomm::Chan<Option<CreatureInfo>>] =
         vec::mapi(set, |ii, col| {
             // create each creature as a listener with a port, and
             // give us a channel to talk to each
@@ -169,8 +172,8 @@ pub fn spawn_listener<A: Owned>(+f: fn~(oldcomm::Port<A>)) -> oldcomm::Chan<A> {
 
     // set up meetings...
     for nn.times {
-        let fst_creature: creature_info = oldcomm::recv(from_creatures);
-        let snd_creature: creature_info = oldcomm::recv(from_creatures);
+        let fst_creature: CreatureInfo = oldcomm::recv(from_creatures);
+        let snd_creature: CreatureInfo = oldcomm::recv(from_creatures);
 
         creatures_met += 2;
 
index ffb32181dc4cffa62440710f72404402a5505fb5..da2f2d5c3d2216d26f9c565a4004b9e6bbfc4217 100644 (file)
 
 fn LINE_LENGTH() -> uint { return 60u; }
 
-type myrandom = @{mut last: u32};
+struct MyRandom {
+    mut last: u32
+}
 
-fn myrandom_next(r: myrandom, mx: u32) -> u32 {
+fn myrandom_next(r: @MyRandom, mx: u32) -> u32 {
     r.last = (r.last * 3877u32 + 29573u32) % 139968u32;
     mx * r.last / 139968u32
 }
 
-type aminoacids = {ch: char, prob: u32};
+struct AminoAcids {
+    ch: char,
+    prob: u32
+}
 
-fn make_cumulative(aa: ~[aminoacids]) -> ~[aminoacids] {
+fn make_cumulative(aa: ~[AminoAcids]) -> ~[AminoAcids] {
     let mut cp: u32 = 0u32;
-    let mut ans: ~[aminoacids] = ~[];
-    for aa.each |a| { cp += a.prob; ans += ~[{ch: a.ch, prob: cp}]; }
+    let mut ans: ~[AminoAcids] = ~[];
+    for aa.each |a| {
+        cp += a.prob;
+        ans += ~[AminoAcids {ch: a.ch, prob: cp}];
+    }
     return ans;
 }
 
-fn select_random(r: u32, genelist: ~[aminoacids]) -> char {
+fn select_random(r: u32, genelist: ~[AminoAcids]) -> char {
     if r < genelist[0].prob { return genelist[0].ch; }
-    fn bisect(v: ~[aminoacids], lo: uint, hi: uint, target: u32) -> char {
+    fn bisect(v: ~[AminoAcids], lo: uint, hi: uint, target: u32) -> char {
         if hi > lo + 1u {
             let mid: uint = lo + (hi - lo) / 2u;
             if target < v[mid].prob {
@@ -46,12 +54,12 @@ fn bisect(v: ~[aminoacids], lo: uint, hi: uint, target: u32) -> char {
             } else { return bisect(v, mid, hi, target); }
         } else { return v[hi].ch; }
     }
-    return bisect(copy genelist, 0, vec::len::<aminoacids>(genelist) - 1, r);
+    return bisect(copy genelist, 0, vec::len::<AminoAcids>(genelist) - 1, r);
 }
 
-fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[aminoacids], n: int) {
+fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[AminoAcids], n: int) {
     wr.write_line(~">" + id + ~" " + desc);
-    let rng = @{mut last: rand::Rng().next()};
+    let rng = @MyRandom {mut last: rand::Rng().next()};
     let mut op: ~str = ~"";
     for uint::range(0u, n as uint) |_i| {
         str::push_char(&mut op, select_random(myrandom_next(rng, 100u32),
@@ -80,7 +88,9 @@ fn make_repeat_fasta(wr: io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
     }
 }
 
-fn acid(ch: char, prob: u32) -> aminoacids { return {ch: ch, prob: prob}; }
+fn acid(ch: char, prob: u32) -> AminoAcids {
+    return AminoAcids {ch: ch, prob: prob};
+}
 
 fn main() {
     let args = os::args();
@@ -102,13 +112,13 @@ fn main() {
 
     let n = int::from_str(args[1]).get();
 
-    let iub: ~[aminoacids] =
+    let iub: ~[AminoAcids] =
         make_cumulative(~[acid('a', 27u32), acid('c', 12u32), acid('g', 12u32),
                          acid('t', 27u32), acid('B', 2u32), acid('D', 2u32),
                          acid('H', 2u32), acid('K', 2u32), acid('M', 2u32),
                          acid('N', 2u32), acid('R', 2u32), acid('S', 2u32),
                          acid('V', 2u32), acid('W', 2u32), acid('Y', 2u32)]);
-    let homosapiens: ~[aminoacids] =
+    let homosapiens: ~[AminoAcids] =
         make_cumulative(~[acid('a', 30u32), acid('c', 20u32), acid('g', 20u32),
                          acid('t', 30u32)]);
     let alu: ~str =
index 75e277e33795b8d59fb704683bebeba5941b54f8..c915820a45a2f11efb7bde3bc91ea0d3163091df 100644 (file)
@@ -36,7 +36,7 @@ fn main() {
         args
     };
     let n = int::from_str(args[1]).get();
-    let mut bodies: ~[Body::props] = NBodySystem::make();
+    let mut bodies: ~[Body::Props] = NBodySystem::make();
     io::println(fmt!("%f", NBodySystem::energy(bodies)));
     let mut i = 0;
     while i < n {
@@ -49,8 +49,8 @@ fn main() {
 mod NBodySystem {
     use Body;
 
-    pub fn make() -> ~[Body::props] {
-        let mut bodies: ~[Body::props] =
+    pub fn make() -> ~[Body::Props] {
+        let mut bodies: ~[Body::Props] =
             ~[Body::sun(),
               Body::jupiter(),
               Body::saturn(),
@@ -76,7 +76,7 @@ pub fn make() -> ~[Body::props] {
         return bodies;
     }
 
-    pub fn advance(bodies: &mut [Body::props], dt: float) {
+    pub fn advance(bodies: &mut [Body::Props], dt: float) {
         let mut i = 0;
         while i < 5 {
             let mut j = i + 1;
@@ -96,8 +96,8 @@ pub fn advance(bodies: &mut [Body::props], dt: float) {
         }
     }
 
-    pub fn advance_one(bi: &mut Body::props,
-                       bj: &mut Body::props,
+    pub fn advance_one(bi: &mut Body::Props,
+                       bj: &mut Body::Props,
                        dt: float) {
         unsafe {
             let dx = bi.x - bj.x;
@@ -119,13 +119,13 @@ pub fn advance_one(bi: &mut Body::props,
         }
     }
 
-    pub fn move_(b: &mut Body::props, dt: float) {
+    pub fn move_(b: &mut Body::Props, dt: float) {
         b.x += dt * b.vx;
         b.y += dt * b.vy;
         b.z += dt * b.vz;
     }
 
-    pub fn energy(bodies: &[Body::props]) -> float {
+    pub fn energy(bodies: &[Body::Props]) -> float {
         unsafe {
             let mut dx;
             let mut dy;
@@ -171,17 +171,17 @@ mod Body {
     // was 4 * PI * PI originally
     pub const DAYS_PER_YEAR: float = 365.24;
 
-    pub type props =
+    pub struct Props
         {mut x: float,
          mut y: float,
          mut z: float,
          mut vx: float,
          mut vy: float,
          mut vz: float,
-         mass: float};
+         mass: float}
 
-    pub fn jupiter() -> Body::props {
-        return {mut x: 4.84143144246472090e+00,
+    pub fn jupiter() -> Body::Props {
+        return Props {mut x: 4.84143144246472090e+00,
              mut y: -1.16032004402742839e+00,
              mut z: -1.03622044471123109e-01,
              mut vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
@@ -190,8 +190,8 @@ pub fn jupiter() -> Body::props {
              mass: 9.54791938424326609e-04 * SOLAR_MASS};
     }
 
-    pub fn saturn() -> Body::props {
-        return {mut x: 8.34336671824457987e+00,
+    pub fn saturn() -> Body::Props {
+        return Props {mut x: 8.34336671824457987e+00,
              mut y: 4.12479856412430479e+00,
              mut z: -4.03523417114321381e-01,
              mut vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
@@ -200,8 +200,8 @@ pub fn saturn() -> Body::props {
              mass: 2.85885980666130812e-04 * SOLAR_MASS};
     }
 
-    pub fn uranus() -> Body::props {
-        return {mut x: 1.28943695621391310e+01,
+    pub fn uranus() -> Body::Props {
+        return Props {mut x: 1.28943695621391310e+01,
              mut y: -1.51111514016986312e+01,
              mut z: -2.23307578892655734e-01,
              mut vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
@@ -210,8 +210,8 @@ pub fn uranus() -> Body::props {
              mass: 4.36624404335156298e-05 * SOLAR_MASS};
     }
 
-    pub fn neptune() -> Body::props {
-        return {mut x: 1.53796971148509165e+01,
+    pub fn neptune() -> Body::Props {
+        return Props {mut x: 1.53796971148509165e+01,
              mut y: -2.59193146099879641e+01,
              mut z: 1.79258772950371181e-01,
              mut vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
@@ -220,8 +220,8 @@ pub fn neptune() -> Body::props {
              mass: 5.15138902046611451e-05 * SOLAR_MASS};
     }
 
-    pub fn sun() -> Body::props {
-        return {mut x: 0.0,
+    pub fn sun() -> Body::Props {
+        return Props {mut x: 0.0,
              mut y: 0.0,
              mut z: 0.0,
              mut vx: 0.0,
@@ -230,7 +230,7 @@ pub fn sun() -> Body::props {
              mass: SOLAR_MASS};
     }
 
-    pub fn offset_momentum(props: &mut Body::props,
+    pub fn offset_momentum(props: &mut Body::Props,
                        px: float, py: float, pz: float) {
         props.vx = -px / SOLAR_MASS;
         props.vy = -py / SOLAR_MASS;
index 80bcb8340542dda03cd84d5be2797415b9530938..b56552d46fe0009e3b01637d59a30472e059a426 100644 (file)
@@ -55,15 +55,19 @@ fn pfib(c: Chan<int>, n: int) {
     p.recv()
 }
 
-type config = {stress: bool};
+struct Config {
+    stress: bool
+}
 
-fn parse_opts(argv: ~[~str]) -> config {
+fn parse_opts(argv: ~[~str]) -> Config {
     let opts = ~[getopts::optflag(~"stress")];
 
-    let opt_args = vec::slice(argv, 1u, vec::len(argv));
+    let opt_args = vec::slice(argv, 1, argv.len());
 
     match getopts::getopts(opt_args, opts) {
-      Ok(ref m) => { return {stress: getopts::opt_present(m, ~"stress")} }
+      Ok(ref m) => {
+          return Config {stress: getopts::opt_present(m, ~"stress")}
+      }
       Err(_) => { fail; }
     }
 }
index 992162f98bf8a2be207832ec3698dac669447d6e..52826752922d567fe7f2bfd083a7c6e50a2e8d4d 100644 (file)
@@ -38,16 +38,15 @@ fn run(repeat: int, depth: int) {
 type nillist = List<()>;
 
 // Filled with things that have to be unwound
-enum st {
-    st_({
-        box: @nillist,
-        unique: ~nillist,
-        fn_box: fn@() -> @nillist,
-        fn_unique: fn~() -> ~nillist,
-        tuple: (@nillist, ~nillist),
-        vec: ~[@nillist],
-        res: r
-    })
+
+struct State {
+    box: @nillist,
+    unique: ~nillist,
+    fn_box: fn@() -> @nillist,
+    fn_unique: fn~() -> ~nillist,
+    tuple: (@nillist, ~nillist),
+    vec: ~[@nillist],
+    res: r
 }
 
 struct r {
@@ -64,7 +63,7 @@ fn r(l: @nillist) -> r {
     }
 }
 
-fn recurse_or_fail(depth: int, st: Option<st>) {
+fn recurse_or_fail(depth: int, st: Option<State>) {
     if depth == 0 {
         debug!("unwinding %.4f", precise_time_s());
         fail;
@@ -73,7 +72,7 @@ fn recurse_or_fail(depth: int, st: Option<st>) {
 
         let st = match st {
           None => {
-            st_({
+            State {
                 box: @Nil,
                 unique: ~Nil,
                 fn_box: fn@() -> @nillist { @Nil::<()> },
@@ -81,13 +80,13 @@ fn recurse_or_fail(depth: int, st: Option<st>) {
                 tuple: (@Nil, ~Nil),
                 vec: ~[@Nil],
                 res: r(@Nil)
-            })
+            }
           }
           Some(st) => {
             let fn_box = st.fn_box;
             let fn_unique = copy st.fn_unique;
 
-            st_({
+            State {
                 box: @Cons((), st.box),
                 unique: ~Cons((), @*st.unique),
                 fn_box: fn@() -> @nillist { @Cons((), fn_box()) },
@@ -97,7 +96,7 @@ fn recurse_or_fail(depth: int, st: Option<st>) {
                         ~Cons((), @*st.tuple.second())),
                 vec: st.vec + ~[@Cons((), st.vec.last())],
                 res: r(@Cons((), st.res._l))
-            })
+            }
           }
         };