Skip to content

Commit fc9650b

Browse files
committed
testsuite: De-record most bench tests
1 parent 3b36708 commit fc9650b

File tree

5 files changed

+78
-62
lines changed

5 files changed

+78
-62
lines changed

src/test/bench/shootout-chameneos-redux.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ fn print_complements() {
2727
2828
enum color { Red, Yellow, Blue }
2929
30-
type creature_info = { name: uint, color: color };
30+
struct CreatureInfo {
31+
name: uint,
32+
color: color
33+
}
3134
3235
fn show_color(cc: color) -> ~str {
3336
match (cc) {
@@ -95,8 +98,8 @@ fn transform(aa: color, bb: color) -> color {
9598
fn creature(
9699
name: uint,
97100
color: color,
98-
from_rendezvous: oldcomm::Port<Option<creature_info>>,
99-
to_rendezvous: oldcomm::Chan<creature_info>,
101+
from_rendezvous: oldcomm::Port<Option<CreatureInfo>>,
102+
to_rendezvous: oldcomm::Chan<CreatureInfo>,
100103
to_rendezvous_log: oldcomm::Chan<~str>
101104
) {
102105
let mut color = color;
@@ -105,7 +108,7 @@ fn creature(
105108
106109
loop {
107110
// ask for a pairing
108-
oldcomm::send(to_rendezvous, {name: name, color: color});
111+
oldcomm::send(to_rendezvous, CreatureInfo {name: name, color: color});
109112
let resp = oldcomm::recv(from_rendezvous);
110113
111114
// log and change, or print and quit
@@ -145,15 +148,15 @@ fn rendezvous(nn: uint, set: ~[color]) {
145148
}
146149
147150
// these ports will allow us to hear from the creatures
148-
let from_creatures: oldcomm::Port<creature_info> = oldcomm::Port();
151+
let from_creatures: oldcomm::Port<CreatureInfo> = oldcomm::Port();
149152
let from_creatures_log: oldcomm::Port<~str> = oldcomm::Port();
150153
151154
// these channels will be passed to the creatures so they can talk to us
152155
let to_rendezvous = oldcomm::Chan(&from_creatures);
153156
let to_rendezvous_log = oldcomm::Chan(&from_creatures_log);
154157
155158
// these channels will allow us to talk to each creature by 'name'/index
156-
let to_creature: ~[oldcomm::Chan<Option<creature_info>>] =
159+
let to_creature: ~[oldcomm::Chan<Option<CreatureInfo>>] =
157160
vec::mapi(set, |ii, col| {
158161
// create each creature as a listener with a port, and
159162
// give us a channel to talk to each
@@ -169,8 +172,8 @@ fn rendezvous(nn: uint, set: ~[color]) {
169172
170173
// set up meetings...
171174
for nn.times {
172-
let fst_creature: creature_info = oldcomm::recv(from_creatures);
173-
let snd_creature: creature_info = oldcomm::recv(from_creatures);
175+
let fst_creature: CreatureInfo = oldcomm::recv(from_creatures);
176+
let snd_creature: CreatureInfo = oldcomm::recv(from_creatures);
174177
175178
creatures_met += 2;
176179

src/test/bench/shootout-fasta.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,46 @@ use io::WriterUtil;
2020

2121
fn LINE_LENGTH() -> uint { return 60u; }
2222

23-
type myrandom = @{mut last: u32};
23+
struct MyRandom {
24+
mut last: u32
25+
}
2426

25-
fn myrandom_next(r: myrandom, mx: u32) -> u32 {
27+
fn myrandom_next(r: @MyRandom, mx: u32) -> u32 {
2628
r.last = (r.last * 3877u32 + 29573u32) % 139968u32;
2729
mx * r.last / 139968u32
2830
}
2931

30-
type aminoacids = {ch: char, prob: u32};
32+
struct AminoAcids {
33+
ch: char,
34+
prob: u32
35+
}
3136

32-
fn make_cumulative(aa: ~[aminoacids]) -> ~[aminoacids] {
37+
fn make_cumulative(aa: ~[AminoAcids]) -> ~[AminoAcids] {
3338
let mut cp: u32 = 0u32;
34-
let mut ans: ~[aminoacids] = ~[];
35-
for aa.each |a| { cp += a.prob; ans += ~[{ch: a.ch, prob: cp}]; }
39+
let mut ans: ~[AminoAcids] = ~[];
40+
for aa.each |a| {
41+
cp += a.prob;
42+
ans += ~[AminoAcids {ch: a.ch, prob: cp}];
43+
}
3644
return ans;
3745
}
3846

39-
fn select_random(r: u32, genelist: ~[aminoacids]) -> char {
47+
fn select_random(r: u32, genelist: ~[AminoAcids]) -> char {
4048
if r < genelist[0].prob { return genelist[0].ch; }
41-
fn bisect(v: ~[aminoacids], lo: uint, hi: uint, target: u32) -> char {
49+
fn bisect(v: ~[AminoAcids], lo: uint, hi: uint, target: u32) -> char {
4250
if hi > lo + 1u {
4351
let mid: uint = lo + (hi - lo) / 2u;
4452
if target < v[mid].prob {
4553
return bisect(v, lo, mid, target);
4654
} else { return bisect(v, mid, hi, target); }
4755
} else { return v[hi].ch; }
4856
}
49-
return bisect(copy genelist, 0, vec::len::<aminoacids>(genelist) - 1, r);
57+
return bisect(copy genelist, 0, vec::len::<AminoAcids>(genelist) - 1, r);
5058
}
5159

52-
fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[aminoacids], n: int) {
60+
fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[AminoAcids], n: int) {
5361
wr.write_line(~">" + id + ~" " + desc);
54-
let rng = @{mut last: rand::Rng().next()};
62+
let rng = @MyRandom {mut last: rand::Rng().next()};
5563
let mut op: ~str = ~"";
5664
for uint::range(0u, n as uint) |_i| {
5765
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) {
8088
}
8189
}
8290

83-
fn acid(ch: char, prob: u32) -> aminoacids { return {ch: ch, prob: prob}; }
91+
fn acid(ch: char, prob: u32) -> AminoAcids {
92+
return AminoAcids {ch: ch, prob: prob};
93+
}
8494

8595
fn main() {
8696
let args = os::args();
@@ -102,13 +112,13 @@ fn main() {
102112

103113
let n = int::from_str(args[1]).get();
104114

105-
let iub: ~[aminoacids] =
115+
let iub: ~[AminoAcids] =
106116
make_cumulative(~[acid('a', 27u32), acid('c', 12u32), acid('g', 12u32),
107117
acid('t', 27u32), acid('B', 2u32), acid('D', 2u32),
108118
acid('H', 2u32), acid('K', 2u32), acid('M', 2u32),
109119
acid('N', 2u32), acid('R', 2u32), acid('S', 2u32),
110120
acid('V', 2u32), acid('W', 2u32), acid('Y', 2u32)]);
111-
let homosapiens: ~[aminoacids] =
121+
let homosapiens: ~[AminoAcids] =
112122
make_cumulative(~[acid('a', 30u32), acid('c', 20u32), acid('g', 20u32),
113123
acid('t', 30u32)]);
114124
let alu: ~str =

src/test/bench/shootout-nbody.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
args
3737
};
3838
let n = int::from_str(args[1]).get();
39-
let mut bodies: ~[Body::props] = NBodySystem::make();
39+
let mut bodies: ~[Body::Props] = NBodySystem::make();
4040
io::println(fmt!("%f", NBodySystem::energy(bodies)));
4141
let mut i = 0;
4242
while i < n {
@@ -49,8 +49,8 @@ fn main() {
4949
mod NBodySystem {
5050
use Body;
5151

52-
pub fn make() -> ~[Body::props] {
53-
let mut bodies: ~[Body::props] =
52+
pub fn make() -> ~[Body::Props] {
53+
let mut bodies: ~[Body::Props] =
5454
~[Body::sun(),
5555
Body::jupiter(),
5656
Body::saturn(),
@@ -76,7 +76,7 @@ mod NBodySystem {
7676
return bodies;
7777
}
7878

79-
pub fn advance(bodies: &mut [Body::props], dt: float) {
79+
pub fn advance(bodies: &mut [Body::Props], dt: float) {
8080
let mut i = 0;
8181
while i < 5 {
8282
let mut j = i + 1;
@@ -96,8 +96,8 @@ mod NBodySystem {
9696
}
9797
}
9898

99-
pub fn advance_one(bi: &mut Body::props,
100-
bj: &mut Body::props,
99+
pub fn advance_one(bi: &mut Body::Props,
100+
bj: &mut Body::Props,
101101
dt: float) {
102102
unsafe {
103103
let dx = bi.x - bj.x;
@@ -119,13 +119,13 @@ mod NBodySystem {
119119
}
120120
}
121121

122-
pub fn move_(b: &mut Body::props, dt: float) {
122+
pub fn move_(b: &mut Body::Props, dt: float) {
123123
b.x += dt * b.vx;
124124
b.y += dt * b.vy;
125125
b.z += dt * b.vz;
126126
}
127127

128-
pub fn energy(bodies: &[Body::props]) -> float {
128+
pub fn energy(bodies: &[Body::Props]) -> float {
129129
unsafe {
130130
let mut dx;
131131
let mut dy;
@@ -171,17 +171,17 @@ mod Body {
171171
// was 4 * PI * PI originally
172172
pub const DAYS_PER_YEAR: float = 365.24;
173173

174-
pub type props =
174+
pub struct Props
175175
{mut x: float,
176176
mut y: float,
177177
mut z: float,
178178
mut vx: float,
179179
mut vy: float,
180180
mut vz: float,
181-
mass: float};
181+
mass: float}
182182

183-
pub fn jupiter() -> Body::props {
184-
return {mut x: 4.84143144246472090e+00,
183+
pub fn jupiter() -> Body::Props {
184+
return Props {mut x: 4.84143144246472090e+00,
185185
mut y: -1.16032004402742839e+00,
186186
mut z: -1.03622044471123109e-01,
187187
mut vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
@@ -190,8 +190,8 @@ mod Body {
190190
mass: 9.54791938424326609e-04 * SOLAR_MASS};
191191
}
192192

193-
pub fn saturn() -> Body::props {
194-
return {mut x: 8.34336671824457987e+00,
193+
pub fn saturn() -> Body::Props {
194+
return Props {mut x: 8.34336671824457987e+00,
195195
mut y: 4.12479856412430479e+00,
196196
mut z: -4.03523417114321381e-01,
197197
mut vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
@@ -200,8 +200,8 @@ mod Body {
200200
mass: 2.85885980666130812e-04 * SOLAR_MASS};
201201
}
202202

203-
pub fn uranus() -> Body::props {
204-
return {mut x: 1.28943695621391310e+01,
203+
pub fn uranus() -> Body::Props {
204+
return Props {mut x: 1.28943695621391310e+01,
205205
mut y: -1.51111514016986312e+01,
206206
mut z: -2.23307578892655734e-01,
207207
mut vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
@@ -210,8 +210,8 @@ mod Body {
210210
mass: 4.36624404335156298e-05 * SOLAR_MASS};
211211
}
212212

213-
pub fn neptune() -> Body::props {
214-
return {mut x: 1.53796971148509165e+01,
213+
pub fn neptune() -> Body::Props {
214+
return Props {mut x: 1.53796971148509165e+01,
215215
mut y: -2.59193146099879641e+01,
216216
mut z: 1.79258772950371181e-01,
217217
mut vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
@@ -220,8 +220,8 @@ mod Body {
220220
mass: 5.15138902046611451e-05 * SOLAR_MASS};
221221
}
222222

223-
pub fn sun() -> Body::props {
224-
return {mut x: 0.0,
223+
pub fn sun() -> Body::Props {
224+
return Props {mut x: 0.0,
225225
mut y: 0.0,
226226
mut z: 0.0,
227227
mut vx: 0.0,
@@ -230,7 +230,7 @@ mod Body {
230230
mass: SOLAR_MASS};
231231
}
232232

233-
pub fn offset_momentum(props: &mut Body::props,
233+
pub fn offset_momentum(props: &mut Body::Props,
234234
px: float, py: float, pz: float) {
235235
props.vx = -px / SOLAR_MASS;
236236
props.vy = -py / SOLAR_MASS;

src/test/bench/shootout-pfib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ fn fib(n: int) -> int {
5555
p.recv()
5656
}
5757

58-
type config = {stress: bool};
58+
struct Config {
59+
stress: bool
60+
}
5961

60-
fn parse_opts(argv: ~[~str]) -> config {
62+
fn parse_opts(argv: ~[~str]) -> Config {
6163
let opts = ~[getopts::optflag(~"stress")];
6264

63-
let opt_args = vec::slice(argv, 1u, vec::len(argv));
65+
let opt_args = vec::slice(argv, 1, argv.len());
6466

6567
match getopts::getopts(opt_args, opts) {
66-
Ok(ref m) => { return {stress: getopts::opt_present(m, ~"stress")} }
68+
Ok(ref m) => {
69+
return Config {stress: getopts::opt_present(m, ~"stress")}
70+
}
6771
Err(_) => { fail; }
6872
}
6973
}

src/test/bench/task-perf-alloc-unwind.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ fn run(repeat: int, depth: int) {
3838
type nillist = List<()>;
3939

4040
// Filled with things that have to be unwound
41-
enum st {
42-
st_({
43-
box: @nillist,
44-
unique: ~nillist,
45-
fn_box: fn@() -> @nillist,
46-
fn_unique: fn~() -> ~nillist,
47-
tuple: (@nillist, ~nillist),
48-
vec: ~[@nillist],
49-
res: r
50-
})
41+
42+
struct State {
43+
box: @nillist,
44+
unique: ~nillist,
45+
fn_box: fn@() -> @nillist,
46+
fn_unique: fn~() -> ~nillist,
47+
tuple: (@nillist, ~nillist),
48+
vec: ~[@nillist],
49+
res: r
5150
}
5251

5352
struct r {
@@ -64,7 +63,7 @@ fn r(l: @nillist) -> r {
6463
}
6564
}
6665

67-
fn recurse_or_fail(depth: int, st: Option<st>) {
66+
fn recurse_or_fail(depth: int, st: Option<State>) {
6867
if depth == 0 {
6968
debug!("unwinding %.4f", precise_time_s());
7069
fail;
@@ -73,21 +72,21 @@ fn recurse_or_fail(depth: int, st: Option<st>) {
7372

7473
let st = match st {
7574
None => {
76-
st_({
75+
State {
7776
box: @Nil,
7877
unique: ~Nil,
7978
fn_box: fn@() -> @nillist { @Nil::<()> },
8079
fn_unique: fn~() -> ~nillist { ~Nil::<()> },
8180
tuple: (@Nil, ~Nil),
8281
vec: ~[@Nil],
8382
res: r(@Nil)
84-
})
83+
}
8584
}
8685
Some(st) => {
8786
let fn_box = st.fn_box;
8887
let fn_unique = copy st.fn_unique;
8988

90-
st_({
89+
State {
9190
box: @Cons((), st.box),
9291
unique: ~Cons((), @*st.unique),
9392
fn_box: fn@() -> @nillist { @Cons((), fn_box()) },
@@ -97,7 +96,7 @@ fn recurse_or_fail(depth: int, st: Option<st>) {
9796
~Cons((), @*st.tuple.second())),
9897
vec: st.vec + ~[@Cons((), st.vec.last())],
9998
res: r(@Cons((), st.res._l))
100-
})
99+
}
101100
}
102101
};
103102

0 commit comments

Comments
 (0)