<commit_before>// Copyright (C) 2012-2018 . All rights reserved.
// Distributed under the terms and conditions of the Apache License.
// See accompanying files LICENSE.

package main

import (
	"flag"
	"log"
	"net"
	"time"
)

func main() {
	var mode, addr string
	var connCount, echoCount int
	flag.StringVar(&addr, "h", "127.0.0.1:8081", "host address")
	flag.IntVar(&connCount, "c", 32, "how many connections to make")
	flag.IntVar(&echoCount, "e", 5, "server response echo back count")
	flag.Parse()

	switch mode {
	case "client":
		startClient(addr, connCount, echoCount)
	case "server":
		startServer(addr, echoCount)
	default:
		log.Panicf("invalid mode: %s", mode)
	}
}

// 开始跑echo client
func startClient(addr string, connCount, echoCount int) {
	var wg sync.WaitGroup
	for i := 0; i < connCount; i++ {
		conn, err := net.Dial("tcp", addr)
		if err != nil {
			log.Fatalf("Dial: %v", err)
		}
		wg.Add(1)
		go handleClientConn(conn, echoCount, &wg)
		time.Sleep(10 * time.Millisecond)
	}
	wg.Wait()
}

//连续发送/接收`echoCount`条消息就close
func handleClientConn(conn net.Conn, echoCount int, wg *sync.WaitGroup) {
	defer wg.Done()<commit_msg>Update echo test<commit_after>// Copyright (C) 2012-2018 . All rights reserved.
// Distributed under the terms and conditions of the Apache License.
// See accompanying files LICENSE.

package main

import (
	"flag"
	"log"
	"net"
	"sync"
	"time"
)

func main() {
	var mode, addr string
	var connCount, echoCount int
	flag.StringVar(&mode, "m", "server", "run server or client")
	flag.StringVar(&addr, "h", "127.0.0.1:8081", "host address")
	flag.IntVar(&connCount, "c", 32, "how many connections to make")
	flag.IntVar(&echoCount, "e", 5, "server response echo back count")
	flag.Parse()

	switch mode {
	case "client":
		startClient(addr, connCount, echoCount)
	case "server":
		startServer(addr, echoCount)
	default:
		log.Panicf("invalid mode: %s", mode)
	}
}

// 开始跑echo client
func startClient(addr string, connCount, echoCount int) {
	log.Printf("starting %d clients to connect %s\n", connCount, addr)
	var wg sync.WaitGroup
	for i := 0; i < connCount; i++ {
		conn, err := net.Dial("tcp", addr)
		if err != nil {
			log.Fatalf("Dial: %v", err)
		}
		wg.Add(1)
		go handleClientConn(conn, echoCount, &wg)
		time.Sleep(10 * time.Millisecond)
	}
	wg.Wait()
}

//连续发送/接收`echoCount`条消息就close
func handleClientConn(conn net.Conn, echoCount int, wg *sync.WaitGroup) {
	defer wg.Done()
{'fraction_non_alphanumeric': 0.14956736711990112, 'fraction_numerical': 0.020601565718994644, 'mean_word_length': 4.154989384288747, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '723114', 'n_tokens_mistral': 966, 'n_tokens_neox': 909, 'n_words': 259}