Пример #1
0
func Test_Snappy(t *testing.T) {
	var (
		f, _ = os.OpenFile("./json.snappy", os.O_WRONLY|os.O_CREATE, 0777)
		g    = snappy.NewWriter(f)
		b    = bufio.NewWriter(g)
		e    = json.NewEncoder(b)
	)
	for i := 0; i < TestLines; i++ {
		e.Encode(TestData)
	}
	b.Flush()
	f.Close()
}
Пример #2
0
func Test_Snappy2_10S(t *testing.T) {
	var (
		g = snappy.NewWriter(&CountWriter{})
		f = &CountProxyWriter{w: g}
		e = json.NewEncoder(f)
		s = time.Now()
	)
	for {
		e.Encode(TestData)
		if time.Since(s) >= time.Second*10 {
			break
		}
	}
	t.Log(f.c/10/1000/1000, "MB/S")
}