Beispiel #1
0
func TestMarshalFaster(t *testing.T) {
	record := newLogFFRecord()
	_, err := ffjson.MarshalFast(record)
	require.NoError(t, err)

	r2 := newLogRecord()
	_, err = ffjson.MarshalFast(r2)
	require.Error(t, err, "Record should not support MarshalFast")
	_, err = ffjson.Marshal(r2)
	require.NoError(t, err)
}
Beispiel #2
0
func BenchmarkFF_Marshal_L(b *testing.B) {
	var l int64
	for i := 0; i < b.N; i++ {
		data, err := ffjson.MarshalFast(&xlStructData)
		if err != nil {
			b.Error(err)
		}
		l = int64(len(data))
	}
	b.SetBytes(l)
}
Beispiel #3
0
func BenchmarkFF_Marshal_L_Parallel(b *testing.B) {
	var l int64
	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			data, err := ffjson.MarshalFast(&xlStructData)
			if err != nil {
				b.Error(err)
			}
			l = int64(len(data))
		}
	})
	b.SetBytes(l)
}
Beispiel #4
0
func BenchmarkMarshalJSONNative(b *testing.B) {
	record := newLogFFRecord()

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

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		_, err := ffjson.MarshalFast(record)
		if err != nil {
			b.Fatalf("Marshal: %v", err)
		}
	}
}