aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/decoder_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-06 19:59:44 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-06 19:59:44 +0200
commit98a22e72a808aa0d5dd62339817404fd9e1c4db6 (patch)
treed5544dce0176b55172f2fd25564618e8c0f18558 /formats/packfile/decoder_test.go
parentae2b10d50da5455b382ab9d543be4fe859afe9e0 (diff)
downloadgo-git-98a22e72a808aa0d5dd62339817404fd9e1c4db6.tar.gz
format: packfile new interface (wip)
Diffstat (limited to 'formats/packfile/decoder_test.go')
-rw-r--r--formats/packfile/decoder_test.go79
1 files changed, 2 insertions, 77 deletions
diff --git a/formats/packfile/decoder_test.go b/formats/packfile/decoder_test.go
index 8c73b4e..5a95af1 100644
--- a/formats/packfile/decoder_test.go
+++ b/formats/packfile/decoder_test.go
@@ -3,16 +3,12 @@ package packfile
import (
"bytes"
"encoding/base64"
- "fmt"
"os"
- "runtime"
"testing"
- "time"
"gopkg.in/src-d/go-git.v4/core"
"gopkg.in/src-d/go-git.v4/storage/memory"
- "github.com/dustin/go-humanize"
. "gopkg.in/check.v1"
)
@@ -27,9 +23,8 @@ var packFileWithEmptyObjects = "UEFDSwAAAAIAAAALnw54nKXMQWoDMQxA0b1PoX2hSLIm44FS
func (s *ReaderSuite) TestReadPackfile(c *C) {
data, _ := base64.StdEncoding.DecodeString(packFileWithEmptyObjects)
f := bytes.NewReader(data)
- r := NewStream(f)
sto := memory.NewStorage()
- d := NewDecoder(r, sto.ObjectStorage())
+ d := NewDecoder(sto.ObjectStorage(), NewParser(f), nil)
err := d.Decode()
c.Assert(err, IsNil)
@@ -60,9 +55,8 @@ func (s *ReaderSuite) TestReadPackfileREFDelta(c *C) {
func (s *ReaderSuite) testReadPackfileGitFixture(c *C, file string, format Format) {
f, err := os.Open(file)
c.Assert(err, IsNil)
- r := NewSeekable(f)
sto := memory.NewStorage()
- d := NewDecoder(r, sto.ObjectStorage())
+ d := NewDecoder(sto.ObjectStorage(), NewParser(f), f)
err = d.Decode()
c.Assert(err, IsNil)
@@ -109,72 +103,3 @@ func AssertObjects(c *C, s *memory.Storage, expects []string) {
c.Assert(obt.Hash().String(), Equals, exp)
}
}
-
-func (s *ReaderSuite) BenchmarkFixtureRef(c *C) {
- for i := 0; i < c.N; i++ {
- readFromFile(c, "fixtures/git-fixture.ref-delta", REFDeltaFormat)
- }
-}
-
-func (s *ReaderSuite) BenchmarkFixtureOfs(c *C) {
- for i := 0; i < c.N; i++ {
- readFromFile(c, "fixtures/git-fixture.ofs-delta", OFSDeltaFormat)
- }
-}
-
-func (s *ReaderSuite) BenchmarkCandyJS(c *C) {
- for i := 0; i < c.N; i++ {
- readFromFile(c, "/tmp/go-candyjs", REFDeltaFormat)
- }
-}
-
-func (s *ReaderSuite) BenchmarkSymfony(c *C) {
- for i := 0; i < c.N; i++ {
- readFromFile(c, "/tmp/symonfy", REFDeltaFormat)
- }
-}
-
-func (s *ReaderSuite) BenchmarkGit(c *C) {
- for i := 0; i < c.N; i++ {
- readFromFile(c, "/tmp/git", REFDeltaFormat)
- }
-}
-
-func (s *ReaderSuite) _testMemory(c *C, format Format) {
- var b, a runtime.MemStats
-
- start := time.Now()
- runtime.ReadMemStats(&b)
- p := readFromFile(c, "/tmp/symfony.ofs-delta", format)
- runtime.ReadMemStats(&a)
-
- fmt.Println("OFS--->")
- fmt.Println("Alloc", a.Alloc-b.Alloc, humanize.Bytes(a.Alloc-b.Alloc))
- fmt.Println("TotalAlloc", a.TotalAlloc-b.TotalAlloc, humanize.Bytes(a.TotalAlloc-b.TotalAlloc))
- fmt.Println("HeapAlloc", a.HeapAlloc-b.HeapAlloc, humanize.Bytes(a.HeapAlloc-b.HeapAlloc))
- fmt.Println("HeapSys", a.HeapSys, humanize.Bytes(a.HeapSys-b.HeapSys))
-
- fmt.Println("objects", len(p.Objects))
- fmt.Println("time", time.Since(start))
-}
-
-func (s *ReaderSuite) _TestMemoryOFS(c *C) {
- s._testMemory(c, OFSDeltaFormat)
-}
-
-func (s *ReaderSuite) _TestMemoryREF(c *C) {
- s._testMemory(c, REFDeltaFormat)
-}
-
-func readFromFile(c *C, file string, format Format) *memory.ObjectStorage {
- f, err := os.Open(file)
- c.Assert(err, IsNil)
- r := NewSeekable(f)
- sto := memory.NewStorage()
- d := NewDecoder(r, sto.ObjectStorage())
-
- err = d.Decode()
- c.Assert(err, IsNil)
-
- return sto.ObjectStorage().(*memory.ObjectStorage)
-}