runtime: scan register backing store on ia64
[official-gcc.git] / libgo / go / runtime / fastlog2_test.go
blobae0f40b2bb7772a8eae364e02fb4660194928092
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package runtime_test
7 import (
8 "math"
9 "runtime"
10 "testing"
13 func TestFastLog2(t *testing.T) {
14 // Compute the euclidean distance between math.Log2 and the FastLog2
15 // implementation over the range of interest for heap sampling.
16 const randomBitCount = 26
17 var e float64
19 inc := 1
20 if testing.Short() {
21 // Check 1K total values, down from 64M.
22 inc = 1 << 16
24 for i := 1; i < 1<<randomBitCount; i += inc {
25 l, fl := math.Log2(float64(i)), runtime.Fastlog2(float64(i))
26 d := l - fl
27 e += d * d
29 e = math.Sqrt(e)
31 if e > 1.0 {
32 t.Fatalf("imprecision on fastlog2 implementation, want <=1.0, got %f", e)