<commit_before>package gob

import (
	"bytes"
	"encoding/gob"
	"fmt"
	"testing"
)

var _ = fmt.Printf

type Data struct {
	N int
	S []byte
	A []byte
}

func TestGobEncoding(t *testing.T) {
	length := 100
	a := make([]byte, length, length)
	for i := 0; i < length; i++ {
		a[i] = byte(i)
	}

	putData := &Data{N: 1, S: []byte{'a', 'b', 'c'}, A: a}

	m := new(bytes.Buffer)
	enc := gob.NewEncoder(m)
	enc.Encode(putData)

	getData := &Data{}
	dec := gob.NewDecoder(m)
	dec.Decode(&getData)

	if getData.N != putData.N ||
		bytes.Compare(getData.S, putData.S) != 0 ||
		bytes.Compare(getData.A, putData.A) != 0 {
		t.Fatal("Gob encoding failed!")
	}
}

func BenchmarkMars(b *testing.B) {
	length := 100
	a := make([]byte, length, length)
	for i := 0; i < length; i++ {
		a[i] = byte(i)
	}

	putData := &Data{N: 1, S: []byte{'a', 'b', 'c'}, A: a}

	m := new(bytes.Buffer)
	enc := gob.NewEncoder(m)
	for i := 0; i < b.N; i++ {
		enc.Encode(putData)
	}
}

func BenchmarkUnma(b *testing.B) {

	length := 100
	a := make([]byte, length, length)
	for i := 0; i < length; i++ {
		a[i] = byte(i)
	}

	putData := &Data{N: 1, S: []byte{'a', 'b', 'c'}, A: a}

	m := new(bytes.Buffer)
	enc := gob.NewEncoder(m)
	enc.Encode(putData)

	getData := &Data{}
	dec := gob.NewDecoder(m)
	for i := 0; i < b.N; i++ {
		dec.Decode(&getData)
	}
}<commit_msg>fix stream decode in gob bench<commit_after>package gob

import (
	"bytes"
	"encoding/gob"
	"fmt"
	"testing"
)

var _ = fmt.Printf

type Data struct {
	N int
	S []byte
	A []byte
}

func TestGobEncoding(t *testing.T) {
	length := 100
	a := make([]byte, length, length)
	for i := 0; i < length; i++ {
		a[i] = byte(i)
	}

	putData := &Data{N: 1, S: []byte{'a', 'b', 'c'}, A: a}

	m := new(bytes.Buffer)
	enc := gob.NewEncoder(m)
	enc.Encode(putData)

	getData := &Data{}
	dec := gob.NewDecoder(m)
	dec.Decode(&getData)

	if getData.N != putData.N ||
		bytes.Compare(getData.S, putData.S) != 0 ||
		bytes.Compare(getData.A, putData.A) != 0 {
		t.Fatal("Gob encoding failed!")
	}
}

func BenchmarkMars(b *testing.B) {
	length := 100
	a := make([]byte, length, length)
	for i := 0; i < length; i++ {
		a[i] = byte(i)
	}

	putData := &Data{N: 1, S: []byte{'a', 'b', 'c'}, A: a}

	m := new(bytes.Buffer)
	enc := gob.NewEncoder(m)
	for i := 0; i < b.N; i++ {
		enc.Encode(putData)
	}
}

func BenchmarkUnma(b *testing.B) {

	length := 100
	a := make([]byte, length, length)
	for i := 0; i < length; i++ {
		a[i] = byte(i)
	}

	putData := &Data{N: 1, S: []byte{'a', 'b', 'c'}, A: a}

	m := new(bytes.Buffer)
	enc := gob.NewEncoder(m)
	for i := 0; i < b.N; i++ {
		enc.Encode(putData)
	}

	b.ResetTimer()

	getData := &Data{}
	dec := gob.NewDecoder(m)
	for i := 0; i < b.N; i++ {
		dec.Decode(&getData)
	}
}
{'fraction_non_alphanumeric': 0.22267057960381512, 'fraction_numerical': 0.014306676449009537, 'mean_word_length': 3.274294670846395, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5851647', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1216, 'n_words': 302}