Exemplo n.º 1
0
func BenchmarkFFUnmarshalJSON(b *testing.B) {
	rec := ff.Log{}
	buf := getBaseData(b)
	b.SetBytes(int64(len(buf)))

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		err := rec.UnmarshalJSON(buf)
		if err != nil {
			b.Fatalf("UnmarshalJSON: %v", err)
		}
	}
}
Exemplo n.º 2
0
func BenchmarkFFMarshalJSON(b *testing.B) {
	var record ff.Log
	ff.NewLog(&record)

	buf, err := record.MarshalJSON()
	if err != nil {
		b.Fatalf("Marshal: %v", err)
	}
	b.SetBytes(int64(len(buf)))

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		_, err := record.MarshalJSON()
		if err != nil {
			b.Fatalf("Marshal: %v", err)
		}
	}
}
Exemplo n.º 3
0
func TestUnmarshal(t *testing.T) {
	rec := ff.Log{}
	buf := getBaseData(t)

	err := rec.UnmarshalJSON(buf)
	if err != nil {
		t.Fatalf("Unmarshal: %v from %s", err, string(buf))
	}

	rec2 := base.Log{}
	json.Unmarshal(buf, &rec2)

	a := fmt.Sprintf("%v", rec)
	b := fmt.Sprintf("%v", rec2)
	if a != b {
		t.Fatalf("Expected: %v\n Got: %v\n from: %s", rec2, rec, string(buf))
	}
}