Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenjl committed Nov 15, 2013
1 parent 8b3cb32 commit 63bd34d
Show file tree
Hide file tree
Showing 29 changed files with 5,484 additions and 5,525 deletions.
34 changes: 17 additions & 17 deletions benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@
package main

import (
"log"
"os"
"fmt"
"bufio"
"io/ioutil"
"flag"
"compress/gzip"
"strconv"
"strings"
"runtime"
"flag"
"fmt"
"github.com/reducedb/encoding"
"github.com/reducedb/encoding/benchtools"
"github.com/reducedb/encoding/composition"
"github.com/reducedb/encoding/fastpfor"
"github.com/reducedb/encoding/bp32"
"github.com/reducedb/encoding/variablebyte"
dfastpfor "github.com/reducedb/encoding/delta/fastpfor"
"github.com/reducedb/encoding/composition"
dbp32 "github.com/reducedb/encoding/delta/bp32"
dfastpfor "github.com/reducedb/encoding/delta/fastpfor"
dvb "github.com/reducedb/encoding/delta/variablebyte"
"github.com/reducedb/encoding/fastpfor"
"github.com/reducedb/encoding/variablebyte"
zbp32 "github.com/reducedb/encoding/zigzag/bp32"
zfastpfor "github.com/reducedb/encoding/zigzag/fastpfor"
"io/ioutil"
"log"
"os"
"runtime"
"strconv"
"strings"
)

type paramList []string

var (
filesParam, dirsParam, codecsParam paramList
pprofParam bool
files []string
pprofParam bool
files []string
)

func (this *paramList) String() string {
Expand All @@ -58,7 +58,7 @@ func init() {
}

func scanIntegers(s *bufio.Scanner) ([]int32, error) {
result := make([]int32,0, 1000000)
result := make([]int32, 0, 1000000)
for s.Scan() {
i, err := strconv.ParseUint(s.Text(), 10, 32)
if err != nil {
Expand Down Expand Up @@ -114,7 +114,7 @@ func getDirOfFiles(path string) ([]string, error) {
}

for _, f := range files {
filenames = append(filenames, path + "/" + f.Name())
filenames = append(filenames, path+"/"+f.Name())
}

return filenames, nil
Expand Down Expand Up @@ -213,7 +213,7 @@ func testCodecs(codecs map[string]encoding.Integer, data [][]int32, output bool)
}

if output {
fmt.Printf("% 20s % 20s: %5.2f %5.2f %5.2f\n", files[i], name, float64(len(out)*32)/float64(k), (float64(k)/(float64(dur)/1000000000.0)/1000000.0), (float64(k)/(float64(dur2)/1000000000.0)/1000000.0))
fmt.Printf("% 20s % 20s: %5.2f %5.2f %5.2f\n", files[i], name, float64(len(out)*32)/float64(k), (float64(k) / (float64(dur) / 1000000000.0) / 1000000.0), (float64(k) / (float64(dur2) / 1000000000.0) / 1000000.0))
}

for i := 0; i < k; i++ {
Expand Down
71 changes: 35 additions & 36 deletions benchtools/benchtools.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
package benchtools

import (
"os"
"io"
"bytes"
"log"
"fmt"
"time"
"code.google.com/p/snappy-go/snappy"
"compress/gzip"
"compress/lzw"
"runtime/pprof"
"code.google.com/p/snappy-go/snappy"
"fmt"
"github.com/reducedb/encoding"
"github.com/reducedb/encoding/cursor"
"io"
"log"
"os"
"runtime/pprof"
"time"
)

func TestCodec(codec encoding.Integer, in []int32, sizes []int) {
Expand All @@ -38,7 +38,7 @@ func TestCodec(codec encoding.Integer, in []int32, sizes []int) {
}

//log.Printf("benchtools/TestCodec: %f %.2f %.2f\n", float64(len(out)*32)/float64(k), (float64(k)/(float64(dur)/1000000000.0)/1000000.0), (float64(k)/(float64(dur2)/1000000000.0)/1000000.0))
fmt.Printf("%f %.2f %.2f\n", float64(len(out)*32)/float64(k), (float64(k)/(float64(dur)/1000000000.0)/1000000.0), (float64(k)/(float64(dur2)/1000000000.0)/1000000.0))
fmt.Printf("%f %.2f %.2f\n", float64(len(out)*32)/float64(k), (float64(k) / (float64(dur) / 1000000000.0) / 1000000.0), (float64(k) / (float64(dur2) / 1000000000.0) / 1000000.0))

for i := 0; i < k; i++ {
if in[i] != out2[i] {
Expand All @@ -64,7 +64,7 @@ func PprofCodec(codec encoding.Integer, in []int32, sizes []int) {
log.Fatal(err2)
}

log.Printf("benchtools/PprofCodec: %f %.2f %.2f\n", float64(len(out)*32)/float64(k), (float64(k)/(float64(dur)/1000000000.0)/1000000.0), (float64(k)/(float64(dur2)/1000000000.0)/1000000.0))
log.Printf("benchtools/PprofCodec: %f %.2f %.2f\n", float64(len(out)*32)/float64(k), (float64(k) / (float64(dur) / 1000000000.0) / 1000000.0), (float64(k) / (float64(dur2) / 1000000000.0) / 1000000.0))

for i := 0; i < k; i++ {
if in[i] != out2[i] {
Expand Down Expand Up @@ -96,54 +96,54 @@ func RunCompress(codec encoding.Integer, in []int32, length int, prof bool) (dur
outpos := cursor.New()

now := time.Now()
if prof {
f, e := os.Create("cpu.compress.pprof")
if e != nil {
log.Fatal(e)
}
defer f.Close()
if prof {
f, e := os.Create("cpu.compress.pprof")
if e != nil {
log.Fatal(e)
}
defer f.Close()

pprof.StartCPUProfile(f)
}
pprof.StartCPUProfile(f)
}

if err = codec.Compress(in, inpos, len(in), out, outpos); err != nil {
return 0, nil, err
}
since := time.Since(now).Nanoseconds()
since := time.Since(now).Nanoseconds()

if prof {
pprof.StopCPUProfile()
}
if prof {
pprof.StopCPUProfile()
}

return since, out[:outpos.Get()], nil
return since, out[:outpos.Get()], nil
}

func RunUncompress(codec encoding.Integer, in []int32, length int, prof bool) (duration int64, out []int32, err error) {
out = make([]int32, length)
inpos := cursor.New()
outpos := cursor.New()

if prof {
f, e := os.Create("cpu.uncompress.pprof")
if e != nil {
log.Fatal(e)
}
defer f.Close()
if prof {
f, e := os.Create("cpu.uncompress.pprof")
if e != nil {
log.Fatal(e)
}
defer f.Close()

pprof.StartCPUProfile(f)
}
pprof.StartCPUProfile(f)
}

now := time.Now()
if err = codec.Uncompress(in, inpos, len(in), out, outpos); err != nil {
return 0, nil, err
}
since := time.Since(now).Nanoseconds()
since := time.Since(now).Nanoseconds()

if prof {
pprof.StopCPUProfile()
}
if prof {
pprof.StopCPUProfile()
}

return since, out[:outpos.Get()], nil
return since, out[:outpos.Get()], nil
}

func RunTestGzip(data []byte) {
Expand Down Expand Up @@ -218,4 +218,3 @@ func RunTestSnappy(data []byte) {
log.Fatalf("encoding/RunTestSnappy: roundtrip mismatch\n")
}
}

Loading

0 comments on commit 63bd34d

Please sign in to comment.