Skip to content

Commit bb71dd7

Browse files
tedhorstcatamorphism
authored andcommitted
---
yaml --- r: 52023 b: refs/heads/dist-snap c: d30224a h: refs/heads/master i: 52021: 8df4d2a 52019: abbf227 52015: 57497e6 v: v3
1 parent 1d258b2 commit bb71dd7

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 8d438747a5121159a1f2bbe10a90f57908f12c2a
10+
refs/heads/dist-snap: d30224a3d477752bf3ff9cfd889e8210a7066f62
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/test/bench/shootout-mandelbrot.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@
1212
// http://shootout.alioth.debian.org/
1313
// u64q/program.php?test=mandelbrot&lang=python3&id=2
1414
//
15-
// takes 3 optional args:
15+
// takes 2 optional args:
1616
// square image size, defaults to 80_u
17-
// yield frequency, defaults to 10_u (yield every 10 spawns)
1817
// output path, default is "" (no output), "-" means stdout
1918
//
2019
// in the shootout, they use 16000 as image size
21-
// yield frequency doesn't seem to have much effect
2220
//
2321
// writes pbm image to output path
2422

25-
#[legacy_modes];
26-
2723
extern mod std;
2824
use io::WriterUtil;
2925
use std::map::HashMap;
@@ -51,7 +47,7 @@ impl cmplx : ops::Add<cmplx,cmplx> {
5147
}
5248
}
5349

54-
type line = {i: uint, b: ~[u8]};
50+
struct Line {i: uint, b: ~[u8]}
5551

5652
pure fn cabs(x: cmplx) -> f64
5753
{
@@ -87,7 +83,7 @@ fn fillbyte(x: cmplx, incr: f64) -> u8 {
8783
rv
8884
}
8985

90-
fn chanmb(i: uint, size: uint, ch: oldcomm::Chan<line>) -> ()
86+
fn chanmb(i: uint, size: uint, ch: oldcomm::Chan<Line>) -> ()
9187
{
9288
let mut crv = ~[];
9389
let incr = 2f64/(size as f64);
@@ -97,22 +93,22 @@ fn chanmb(i: uint, size: uint, ch: oldcomm::Chan<line>) -> ()
9793
let x = cmplx {re: xincr*(j as f64) - 1.5f64, im: y};
9894
crv.push(fillbyte(x, incr));
9995
};
100-
oldcomm::send(ch, {i:i, b:crv});
96+
oldcomm::send(ch, Line {i:i, b: move crv});
10197
}
10298

10399
type devnull = {dn: int};
104100

105101
impl devnull: io::Writer {
106102
fn write(_b: &[const u8]) {}
107-
fn seek(+_i: int, +_s: io::SeekStyle) {}
103+
fn seek(_i: int, _s: io::SeekStyle) {}
108104
fn tell() -> uint {0_u}
109105
fn flush() -> int {0}
110106
fn get_type() -> io::WriterType { io::File }
111107
}
112108

113-
fn writer(path: ~str, writech: oldcomm::Chan<oldcomm::Chan<line>>, size: uint)
109+
fn writer(path: ~str, writech: oldcomm::Chan<oldcomm::Chan<Line>>, size: uint)
114110
{
115-
let p: oldcomm::Port<line> = oldcomm::Port();
111+
let p: oldcomm::Port<Line> = oldcomm::Port();
116112
let ch = oldcomm::Chan(&p);
117113
oldcomm::send(writech, ch);
118114
let cout: io::Writer = match path {
@@ -164,16 +160,13 @@ fn writer(path: ~str, writech: oldcomm::Chan<oldcomm::Chan<line>>, size: uint)
164160
fn main() {
165161
let args = os::args();
166162
let args = if os::getenv(~"RUST_BENCH").is_some() {
167-
~[~"", ~"4000", ~"10"]
163+
~[~"", ~"4000"]
168164
} else {
169165
args
170166
};
171167

172-
let path = if vec::len(args) < 4_u { ~"" }
173-
else { copy args[3] }; // FIXME: bad for perf
174-
175-
let yieldevery = if vec::len(args) < 3_u { 10_u }
176-
else { uint::from_str(args[2]).get() };
168+
let path = if vec::len(args) < 3_u { ~"" }
169+
else { copy args[2] }; // FIXME: bad for perf
177170

178171
let size = if vec::len(args) < 2_u { 80_u }
179172
else { uint::from_str(args[1]).get() };
@@ -185,10 +178,6 @@ fn main() {
185178
};
186179
let ch = oldcomm::recv(writep);
187180
for uint::range(0_u, size) |j| {
188-
task::spawn(|| chanmb(j, size, ch) );
189-
if j % yieldevery == 0_u {
190-
debug!("Y %u", j);
191-
task::yield();
192-
};
181+
do task::spawn { chanmb(j, size, ch) };
193182
};
194183
}

0 commit comments

Comments
 (0)