<commit_before>package main

import "github.com/rogeralsing/gam/actor"
import "github.com/rogeralsing/gam/remoting"

import "log"
import "sync"

import "time"

// import "runtime/pprof"
import "github.com/rogeralsing/gam/examples/remoting/messages"
import "runtime"

type localActor struct {
	count        int
	wgStop       *sync.WaitGroup
	start        time.Time
	messageCount int
}

func (state *localActor) Receive(context actor.Context) {
	switch context.Message().(type) {
	case *messages.Pong:
		state.count++
		if state.count%50000 == 0 {
			log.Println(state.count)
		}
		if state.count == state.messageCount {
			elapsed := time.Since(state.start)
			log.Printf("Elapsed %s", elapsed)

			x := int(float32(state.messageCount*2) / (float32(elapsed) / float32(time.Second)))
			log.Printf("Msg per sec %v", x)

			state.wgStop.Done()
		}
	case *messages.Start:
		log.Println("Starting")
		state.start = time.Now()
	}
}

func main() {
	runtime.GOMAXPROCS(8)
	// f, err := os.Create("cpuprofile")
	// if err != nil {
	// 	log.Fatal(err)
	// }
	// pprof.StartCPUProfile(f)
	// defer pprof.StopCPUProfile()
	var wgStop sync.WaitGroup
	wgStop.Add(1)
	var wgStart sync.WaitGroup
	wgStart.Add(1)

	messageCount := 1000000
	fillers := 50

	remoting.StartServer("localhost:8090")

	pid := actor.SpawnTemplate(&localActor{
		wgStop:       &wgStop,
		messageCount: messageCount,
	})

	message := &messages.Ping{Sender: pid}
	remote := actor.NewPID("localhost:8091", "remote")
	remote.Tell(&messages.StartRemote{Sender: pid})
	for j := 0; j < fillers; j++ {
		go func() {
			for i := 0; i < messageCount/fillers; i++ {
				remote.Tell(message)
			}
		}()
	}

	wgStop.Wait()
}<commit_msg>fix benchmark bug<commit_after>package main

import "github.com/rogeralsing/gam/actor"
import "github.com/rogeralsing/gam/remoting"

import "log"
import "sync"

import "time"

// import "runtime/pprof"
import "github.com/rogeralsing/gam/examples/remoting/messages"
import "runtime"

type localActor struct {
	count        int
	wgStart      *sync.WaitGroup
	wgStop       *sync.WaitGroup
	start        time.Time
	messageCount int
}

func (state *localActor) Receive(context actor.Context) {
	switch context.Message().(type) {
	case *messages.Pong:
		state.count++
		if state.count%50000 == 0 {
			log.Println(state.count)
		}
		if state.count == state.messageCount {
			elapsed := time.Since(state.start)
			log.Printf("Elapsed %s", elapsed)

			x := int(float32(state.messageCount*2) / (float32(elapsed) / float32(time.Second)))
			log.Printf("Msg per sec %v", x)

			state.wgStop.Done()
		}
	case *messages.Start:
		log.Println("Starting")
		state.wgStart.Done()
		state.start = time.Now()
	}
}

func main() {
	runtime.GOMAXPROCS(8)
	// f, err := os.Create("cpuprofile")
	// if err != nil {
	// 	log.Fatal(err)
	// }
	// pprof.StartCPUProfile(f)
	// defer pprof.StopCPUProfile()
	var wgStop sync.WaitGroup
	wgStop.Add(1)
	var wgStart sync.WaitGroup
	wgStart.Add(1)

	messageCount := 1000000
	fillers := 50

	remoting.StartServer("localhost:8090")

	pid := actor.SpawnTemplate(&localActor{
		wgStart:      &wgStart,
		wgStop:       &wgStop,
		messageCount: messageCount,
	})

	message := &messages.Ping{Sender: pid}
	remote := actor.NewPID("localhost:8091", "remote")
	remote.Tell(&messages.StartRemote{Sender: pid})
	wgStart.Wait()
	log.Println("Starting to send")	
	for j := 0; j < fillers; j++ {
		go func() {
			for i := 0; i < messageCount/fillers; i++ {
				remote.Tell(message)
			}
		}()
	}

	wgStop.Wait()
}
{'fraction_non_alphanumeric': 0.15413211323991993, 'fraction_numerical': 0.020017157563625966, 'mean_word_length': 3.620871862615588, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4915247', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1303, 'n_words': 255}