diff options
author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:41:46 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:41:46 -0800 |
commit | 3743fa38e180c74c51aae84eda082067e8e12523 (patch) | |
tree | 274d1d9bf832b7834ab60c65acdf945576271d14 /test/bench/binary-tree.go | |
parent | 13ac778ef2f757c7cd636b4336a2bd6c8f403b43 (diff) | |
download | golang-3743fa38e180c74c51aae84eda082067e8e12523.tar.gz |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
5th and last set of files.
R=rsc
CC=golang-dev
http://codereview.appspot.com/180050
Diffstat (limited to 'test/bench/binary-tree.go')
-rw-r--r-- | test/bench/binary-tree.go | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/test/bench/binary-tree.go b/test/bench/binary-tree.go index 88497d490..9f867d11a 100644 --- a/test/bench/binary-tree.go +++ b/test/bench/binary-tree.go @@ -37,56 +37,56 @@ POSSIBILITY OF SUCH DAMAGE. package main import ( - "flag"; - "fmt"; + "flag" + "fmt" ) var n = flag.Int("n", 15, "depth") type Node struct { - item int; - left, right *Node; + item int + left, right *Node } func bottomUpTree(item, depth int) *Node { if depth <= 0 { return &Node{item: item} } - return &Node{item, bottomUpTree(2*item-1, depth-1), bottomUpTree(2*item, depth-1)}; + return &Node{item, bottomUpTree(2*item-1, depth-1), bottomUpTree(2*item, depth-1)} } func (n *Node) itemCheck() int { if n.left == nil { return n.item } - return n.item + n.left.itemCheck() - n.right.itemCheck(); + return n.item + n.left.itemCheck() - n.right.itemCheck() } const minDepth = 4 func main() { - flag.Parse(); + flag.Parse() - maxDepth := *n; + maxDepth := *n if minDepth+2 > *n { maxDepth = minDepth + 2 } - stretchDepth := maxDepth + 1; + stretchDepth := maxDepth + 1 - check := bottomUpTree(0, stretchDepth).itemCheck(); - fmt.Printf("stretch tree of depth %d\t check: %d\n", stretchDepth, check); + check := bottomUpTree(0, stretchDepth).itemCheck() + fmt.Printf("stretch tree of depth %d\t check: %d\n", stretchDepth, check) - longLivedTree := bottomUpTree(0, maxDepth); + longLivedTree := bottomUpTree(0, maxDepth) for depth := minDepth; depth <= maxDepth; depth += 2 { - iterations := 1 << uint(maxDepth-depth+minDepth); - check = 0; + iterations := 1 << uint(maxDepth-depth+minDepth) + check = 0 for i := 1; i <= iterations; i++ { - check += bottomUpTree(i, depth).itemCheck(); - check += bottomUpTree(-i, depth).itemCheck(); + check += bottomUpTree(i, depth).itemCheck() + check += bottomUpTree(-i, depth).itemCheck() } - fmt.Printf("%d\t trees of depth %d\t check: %d\n", iterations*2, depth, check); + fmt.Printf("%d\t trees of depth %d\t check: %d\n", iterations*2, depth, check) } - fmt.Printf("long lived tree of depth %d\t check: %d\n", maxDepth, longLivedTree.itemCheck()); + fmt.Printf("long lived tree of depth %d\t check: %d\n", maxDepth, longLivedTree.itemCheck()) } |