Skip to content

Commit fc0ca80

Browse files
committed
---
yaml --- r: 39554 b: refs/heads/incoming c: 2452ee1 h: refs/heads/master v: v3
1 parent 4c0ef24 commit fc0ca80

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
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: 10e8e3e2860bc78cb19158028404a8938f62b93c
9+
refs/heads/incoming: 2452ee11abd1aab42adbf4e8e6455dd74e2a5aa9
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/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)