<commit_before>package main

import (
	"fmt"
	"log"
	"net"
	"os"
	"sync"
	"time"

	"github.com/rosshendrickson-wf/education/examples/toyserver/message"
)

var count = 0
var vcount = 0

var revision = 0
var connections = make(map[net.Addr]*Connection, 0)

type Connection struct {
	name     int
	revision int
	ready    bool
	mu       sync.RWMutex
}

func (c *Connection) SetRevisionReady(revision int, ready bool) {

	c.mu.Lock()
	c.revision = revision
	c.ready = ready
	c.mu.Unlock()
	//println("Udate connection rev & ready", revision, ready)
}

func (c *Connection) GetReady() bool {

	c.mu.RLock()
	r := c.ready
	c.mu.RUnlock()
	return r
}

func main() {

	ticker := time.NewTicker(time.Second * 2)
	go func() {
		for _ = range ticker.C {
			log.Printf("Processed ~%d Frames", count/2)
			count = 0
		}
	}()

	// Listen for incoming connections.
	l, err := net.Listen("tcp", "localhost:8001")
	if err != nil {
		fmt.Println("Error listening:", err.Error())
		os.Exit(1)
	}
	// Close the listener when the application
	// closes.
	defer l.Close()
	fmt.Println("Listening on " + "local 8001")
	for {
		// Listen for an
		// incoming
		// connection.
		conn, err := l.Accept()
		if err != nil {
			fmt.Println("Error accepting: ", err.Error())
			os.Exit(1)
		}
		go incrementRevision(conn)
		go handleRequest(conn)
	}
}

func incrementRevision(conn net.Conn) {
	for {
		time.Sleep(time.Second * 1 / 300)
		ready := true
		for _, v := range connections {
			if !v.GetReady() {
				ready = false
				break
			}
		}
		if !ready || len(connections) == 0 {
			continue
		}
		revision++
		if revision > 10000 {
			os.Exit(1)
		}
		count++<commit_msg>1000 fps tests<commit_after>package main

import (
	"fmt"
	"log"
	"net"
	"os"
	"sync"
	"time"

	"github.com/rosshendrickson-wf/education/examples/toyserver/message"
)

var count = 0
var vcount = 0

var revision = 0
var connections = make(map[net.Addr]*Connection, 0)

type Connection struct {
	name     int
	revision int
	ready    bool
	mu       sync.RWMutex
}

func (c *Connection) SetRevisionReady(revision int, ready bool) {

	c.mu.Lock()
	c.revision = revision
	c.ready = ready
	c.mu.Unlock()
	//println("Udate connection rev & ready", revision, ready)
}

func (c *Connection) GetReady() bool {

	c.mu.RLock()
	r := c.ready
	c.mu.RUnlock()
	return r
}

func main() {

	ticker := time.NewTicker(time.Second * 2)
	go func() {
		for _ = range ticker.C {
			log.Printf("Processed ~%d Frames", count/2)
			count = 0
		}
	}()

	// Listen for incoming connections.
	l, err := net.Listen("tcp", "localhost:8001")
	if err != nil {
		fmt.Println("Error listening:", err.Error())
		os.Exit(1)
	}
	// Close the listener when the application
	// closes.
	defer l.Close()
	fmt.Println("Listening on " + "local 8001")
	for {
		// Listen for an
		// incoming
		// connection.
		conn, err := l.Accept()
		if err != nil {
			fmt.Println("Error accepting: ", err.Error())
			os.Exit(1)
		}
		go incrementRevision(conn)
		go handleRequest(conn)
	}
}

func incrementRevision(conn net.Conn) {
	for {
		time.Sleep(time.Second * 1 / 1000)
		ready := true
		for _, v := range connections {
			if !v.GetReady() {
				ready = false
				break
			}
		}
		if !ready || len(connections) == 0 {
			continue
		}
		revision++
		if revision > 1000000 {
			os.Exit(1)
		}
		count++
{'fraction_non_alphanumeric': 0.1493624772313297, 'fraction_numerical': 0.01912568306010929, 'mean_word_length': 2.9555822328931574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2342910', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1231, 'n_words': 315}