<commit_before>package synapse

import (
	"net"
	"net/rpc"
	"testing"
)

func TestCodecs(t *testing.T) {
	// create fake network
	cl, srv := net.Pipe()

	ccd := &clientCodec{conn: cl}
	scd := &serverCodec{conn: srv}

	server := rpc.NewServer()
	server.Register(Echo{})
	go server.ServeCodec(scd)

	client := rpc.NewClientWithCodec(ccd)

	out := &Arg2{}
	in := &Arg1{Value: "Hello, world!"}
	err := client.Call("Echo.Echo", in, out)
	if err != nil {
		t.Fatal(err)
	}

	if out.Value != in.Value {
		t.Fatalf("%q in; %q out", in.Value, out.Value)
	}

	cl.Close()
}<commit_msg>bench<commit_after>package synapse

import (
	"net"
	"net/rpc"
	"testing"
)

func TestCodecs(t *testing.T) {
	// create fake network
	cl, srv := net.Pipe()

	ccd := &clientCodec{conn: cl}
	scd := &serverCodec{conn: srv}

	server := rpc.NewServer()
	server.Register(Echo{})
	go server.ServeCodec(scd)

	client := rpc.NewClientWithCodec(ccd)

	out := &Arg2{}
	in := &Arg1{Value: "Hello, world!"}
	err := client.Call("Echo.Echo", in, out)
	if err != nil {
		t.Fatal(err)
	}

	if out.Value != in.Value {
		t.Fatalf("%q in; %q out", in.Value, out.Value)
	}

	cl.Close()
}

func BenchmarkBasicCodec(b *testing.B) {
	cl, srv := net.Pipe()
	ccd := &clientCodec{conn: cl}
	scd := &serverCodec{conn: srv}
	server := rpc.NewServer()
	server.Register(Echo{})
	go server.ServeCodec(scd)
	client := rpc.NewClientWithCodec(ccd)
	out := &Arg2{}
	in := &Arg1{Value: "Hello, world!"}

	b.ResetTimer()
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		err := client.Call("Echo.Echo", in, out)
		if err != nil {
			b.Fatal(err)
		}
	}
	cl.Close()
}
{'fraction_non_alphanumeric': 0.194375, 'fraction_numerical': 0.004375, 'mean_word_length': 3.7648809523809526, 'pattern_counts': {'":': 0, '<': 4, '<?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': '5765386', 'n_tokens_mistral': 714, 'n_tokens_neox': 700, 'n_words': 146}