Commit 09045306 authored by Jeromy's avatar Jeromy

vendor correctly

parent df0989a3
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
"ImportPath": "github.com/codahale/metrics", "ImportPath": "github.com/codahale/metrics",
"Rev": "7d3beb1b480077e77c08a6f6c65ea969f6e91420" "Rev": "7d3beb1b480077e77c08a6f6c65ea969f6e91420"
}, },
{
"ImportPath": "github.com/dustin/randbo",
"Rev": "7f1b564ca7242d22bcc6e2128beb90d9fa38b9f0"
},
{ {
"ImportPath": "github.com/hashicorp/golang-lru", "ImportPath": "github.com/hashicorp/golang-lru",
"Rev": "4dfff096c4973178c8f35cf6dd1a732a0a139370" "Rev": "4dfff096c4973178c8f35cf6dd1a732a0a139370"
...@@ -29,10 +33,6 @@ ...@@ -29,10 +33,6 @@
"ImportPath": "github.com/jbenet/goprocess", "ImportPath": "github.com/jbenet/goprocess",
"Rev": "5b02f8d275a2dd882fb06f8bbdf74347795ff3b1" "Rev": "5b02f8d275a2dd882fb06f8bbdf74347795ff3b1"
}, },
{
"ImportPath": "github.com/satori/go.uuid",
"Rev": "7c7f2020c4c9491594b85767967f4619c2fa75f9"
},
{ {
"ImportPath": "github.com/mattbaird/elastigo/api", "ImportPath": "github.com/mattbaird/elastigo/api",
"Rev": "041b88c1fcf6489a5721ede24378ce1253b9159d" "Rev": "041b88c1fcf6489a5721ede24378ce1253b9159d"
...@@ -41,6 +41,10 @@ ...@@ -41,6 +41,10 @@
"ImportPath": "github.com/mattbaird/elastigo/core", "ImportPath": "github.com/mattbaird/elastigo/core",
"Rev": "041b88c1fcf6489a5721ede24378ce1253b9159d" "Rev": "041b88c1fcf6489a5721ede24378ce1253b9159d"
}, },
{
"ImportPath": "github.com/satori/go.uuid",
"Rev": "7c7f2020c4c9491594b85767967f4619c2fa75f9"
},
{ {
"ImportPath": "github.com/syndtr/goleveldb/leveldb", "ImportPath": "github.com/syndtr/goleveldb/leveldb",
"Rev": "871eee0a7546bb7d1b2795142e29c4534abc49b3" "Rev": "871eee0a7546bb7d1b2795142e29c4534abc49b3"
......
A fast random number `io.Reader` implementation.
![randbo](https://raw.github.com/dustin/randbo/master/randbo.png)
> IN A WORLD where no integer sequence is certain ...
>
> ONE MAN must become statistically indistinguishable from noise
>
> THIS SUMMER, entropy has a new name: RANDBO
(thanks @snej)
package randbo
import (
"io"
"math/rand"
"time"
)
// Randbo creates a stream of non-crypto quality random bytes
type randbo struct {
rand.Source
}
// New creates a new random reader with a time source.
func New() io.Reader {
return NewFrom(rand.NewSource(time.Now().UnixNano()))
}
// NewFrom creates a new reader from your own rand.Source
func NewFrom(src rand.Source) io.Reader {
return &randbo{src}
}
// Read satisfies io.Reader
func (r *randbo) Read(p []byte) (n int, err error) {
todo := len(p)
offset := 0
for {
val := int64(r.Int63())
for i := 0; i < 8; i++ {
p[offset] = byte(val)
todo--
if todo == 0 {
return len(p), nil
}
offset++
val >>= 8
}
}
}
package randbo
import (
"crypto/rand"
"io"
"io/ioutil"
"testing"
)
func TestRandbo(t *testing.T) {
buf := make([]byte, 16)
n, err := New().Read(buf)
if err != nil {
t.Fatalf("Error reading: %v", err)
}
if n != len(buf) {
t.Fatalf("Short read: %v", n)
}
t.Logf("Read %x", buf)
}
const toCopy = 1024 * 1024
func BenchmarkRandbo(b *testing.B) {
b.SetBytes(toCopy)
r := New()
for i := 0; i < b.N; i++ {
io.CopyN(ioutil.Discard, r, toCopy)
}
}
func BenchmarkCrypto(b *testing.B) {
b.SetBytes(toCopy)
for i := 0; i < b.N; i++ {
io.CopyN(ioutil.Discard, rand.Reader, toCopy)
}
}
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
"github.com/jbenet/go-datastore/flatfs" "github.com/jbenet/go-datastore/flatfs"
"github.com/jbenet/go-datastore/query" "github.com/jbenet/go-datastore/query"
rand "github.com/dustin/randbo" rand "github.com/jbenet/go-datastore/Godeps/_workspace/src/github.com/dustin/randbo"
) )
func tempdir(t testing.TB) (path string, cleanup func()) { func tempdir(t testing.TB) (path string, cleanup func()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment