1
0
mirror of https://github.com/golang/go synced 2024-11-22 05:14:40 -07:00

test/garbage: move to test/bench/garbage

(These are benchmarks for the garbage collector, not tests.)

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5484070
This commit is contained in:
Russ Cox 2011-12-13 18:02:49 -05:00
parent 1161e1172b
commit 5fe96c640a
7 changed files with 8 additions and 20 deletions

View File

@ -24,7 +24,7 @@ for i in lib9 libbio libmach cmd pkg \
../misc/cgo/life ../misc/cgo/test \ ../misc/cgo/life ../misc/cgo/test \
../misc/dashboard/builder ../misc/goplay\ ../misc/dashboard/builder ../misc/goplay\
../doc/codelab/wiki\ ../doc/codelab/wiki\
../test/bench/shootout ../test/garbage ../test/bench/shootout ../test/bench/garbage
do do
# Do not use gomake here. It may not be available. # Do not use gomake here. It may not be available.
$MAKE -C "$GOROOT/src/$i" clean $MAKE -C "$GOROOT/src/$i" clean

View File

@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style # Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file. # license that can be found in the LICENSE file.
include ../../src/Make.inc include ../../../src/Make.inc
ALL=\ ALL=\
parser\ parser\

View File

@ -12,31 +12,25 @@ import (
"time" "time"
) )
type Number struct { type Number struct {
next *Number next *Number
} }
// ------------------------------------- // -------------------------------------
// Peano primitives // Peano primitives
func zero() *Number { return nil } func zero() *Number { return nil }
func is_zero(x *Number) bool { return x == nil } func is_zero(x *Number) bool { return x == nil }
func add1(x *Number) *Number { func add1(x *Number) *Number {
e := new(Number) e := new(Number)
e.next = x e.next = x
return e return e
} }
func sub1(x *Number) *Number { return x.next } func sub1(x *Number) *Number { return x.next }
func add(x, y *Number) *Number { func add(x, y *Number) *Number {
if is_zero(y) { if is_zero(y) {
return x return x
@ -45,7 +39,6 @@ func add(x, y *Number) *Number {
return add(add1(x), sub1(y)) return add(add1(x), sub1(y))
} }
func mul(x, y *Number) *Number { func mul(x, y *Number) *Number {
if is_zero(x) || is_zero(y) { if is_zero(x) || is_zero(y) {
return zero() return zero()
@ -54,7 +47,6 @@ func mul(x, y *Number) *Number {
return add(mul(x, sub1(y)), x) return add(mul(x, sub1(y)), x)
} }
func fact(n *Number) *Number { func fact(n *Number) *Number {
if is_zero(n) { if is_zero(n) {
return add1(zero()) return add1(zero())
@ -63,7 +55,6 @@ func fact(n *Number) *Number {
return mul(fact(sub1(n)), n) return mul(fact(sub1(n)), n)
} }
// ------------------------------------- // -------------------------------------
// Helpers to generate/count Peano integers // Helpers to generate/count Peano integers
@ -75,7 +66,6 @@ func gen(n int) *Number {
return zero() return zero()
} }
func count(x *Number) int { func count(x *Number) int {
if is_zero(x) { if is_zero(x) {
return 0 return 0
@ -84,7 +74,6 @@ func count(x *Number) int {
return count(sub1(x)) + 1 return count(sub1(x)) + 1
} }
func check(x *Number, expected int) { func check(x *Number, expected int) {
var c = count(x) var c = count(x)
if c != expected { if c != expected {
@ -92,7 +81,6 @@ func check(x *Number, expected int) {
} }
} }
// ------------------------------------- // -------------------------------------
// Test basic functionality // Test basic functionality
@ -117,7 +105,6 @@ func verify() {
check(fact(gen(5)), 120) check(fact(gen(5)), 120)
} }
// ------------------------------------- // -------------------------------------
// Factorial // Factorial

View File

@ -27,6 +27,7 @@ func gcstats(name string, n int, t int64) {
} }
type T []uint64 type T []uint64
func (t T) Len() int { return len(t) } func (t T) Len() int { return len(t) }
func (t T) Swap(i, j int) { t[i], t[j] = t[j], t[i] } func (t T) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
func (t T) Less(i, j int) bool { return t[i] < t[j] } func (t T) Less(i, j int) bool { return t[i] < t[j] }

View File

@ -5,7 +5,7 @@
set -e set -e
eval $(gomake --no-print-directory -f ../../src/Make.inc go-env) eval $(gomake --no-print-directory -f ../../../src/Make.inc go-env)
PATH=.:$PATH PATH=.:$PATH
havegccgo=false havegccgo=false