bench: Update shootout-binarytrees for style
This commit is contained in:
parent
c53d0a0af8
commit
9c21673e3f
1 changed files with 15 additions and 8 deletions
|
@ -19,8 +19,12 @@ fn bottom_up_tree(item: int, depth: int) -> ~tree {
|
||||||
} else { ret ~nil; }
|
} else { ret ~nil; }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main(args: [str]) {
|
||||||
let n = 8;
|
let n = if vec::len(args) == 2u {
|
||||||
|
int::from_str(args[1])
|
||||||
|
} else {
|
||||||
|
15
|
||||||
|
};
|
||||||
let min_depth = 4;
|
let min_depth = 4;
|
||||||
let max_depth;
|
let max_depth;
|
||||||
if min_depth + 2 > n {
|
if min_depth + 2 > n {
|
||||||
|
@ -28,8 +32,9 @@ fn main() {
|
||||||
} else { max_depth = n; }
|
} else { max_depth = n; }
|
||||||
let stretch_depth = max_depth + 1;
|
let stretch_depth = max_depth + 1;
|
||||||
let stretch_tree = bottom_up_tree(0, stretch_depth);
|
let stretch_tree = bottom_up_tree(0, stretch_depth);
|
||||||
#debug("stretch tree of depth %d\t check: %d", stretch_depth,
|
std::io::println(#fmt("stretch tree of depth %d\t check: %d",
|
||||||
item_check(stretch_tree));
|
stretch_depth,
|
||||||
|
item_check(stretch_tree)));
|
||||||
let long_lived_tree = bottom_up_tree(0, max_depth);
|
let long_lived_tree = bottom_up_tree(0, max_depth);
|
||||||
let depth = min_depth;
|
let depth = min_depth;
|
||||||
while depth <= max_depth {
|
while depth <= max_depth {
|
||||||
|
@ -43,10 +48,12 @@ fn main() {
|
||||||
chk += item_check(temp_tree);
|
chk += item_check(temp_tree);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
#debug("%d\t trees of depth %d\t check: %d", iterations * 2, depth,
|
std::io::println(#fmt("%d\t trees of depth %d\t check: %d",
|
||||||
chk);
|
iterations * 2, depth,
|
||||||
|
chk));
|
||||||
depth += 2;
|
depth += 2;
|
||||||
}
|
}
|
||||||
#debug("long lived trees of depth %d\t check: %d", max_depth,
|
std::io::println(#fmt("long lived trees of depth %d\t check: %d",
|
||||||
item_check(long_lived_tree));
|
max_depth,
|
||||||
|
item_check(long_lived_tree)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue