コード例 #1
0
ファイル: test.go プロジェクト: zeb209/buffstreams
// This is not a proper test, but it lets me benchmark how it
// performs on a raw level. Run this with the time command
func main() {
	cfg := buffstreams.BuffManagerConfig{
		MaxMessageSize: 256,
	}
	// 100 byte message
	msg := []byte("HeyheyheyHeyheyheyHeyheyheyHeyheyheyHeyheyheyHeyheyheyHeyheyheyHeyheyheyHeyheyheyHeyheyheyHeyheyheyH!")
	startingPort := 5031
	for i := 0; i < 10; i++ {
		go func(n int, port string) {
			bm := buffstreams.New(cfg)
			bm.StartListening(strconv.Itoa(startingPort), TestCallback)
			address := buffstreams.FormatAddress("127.0.0.1", strconv.Itoa(startingPort))
			count := 0
			for {
				_, err := bm.WriteTo(address, msg, true)
				if err != nil {
					log.Print("EEEEEERRRRROOOOOOOORRRRRRRRRRR")
					log.Print(err)
				}
				count = count + 1
				log.Printf("%d - %d", n, count)
			}
		}(i, strconv.Itoa(startingPort))
		startingPort = startingPort + 1
	}
	time.Sleep(time.Minute * 10)
}
コード例 #2
0
ファイル: test_client.go プロジェクト: ezbercih/buffstreams
// Test client to send a sample payload of data endlessly
// By default it points locally, but it can point to any network address
// TODO Make that externally configurable to make automating the test easier
func main() {
	cfg := buffstreams.BuffManagerConfig{
		MaxMessageSize: 2048,
		EnableLogging:  true,
	}
	name := "Stabby"
	date := time.Now().UnixNano()
	data := "This is an intenntionally long and rambling sentence to pad out the size of the message."
	msg := &message.Note{Name: &name, Date: &date, Comment: &data}
	msgBytes, err := proto.Marshal(msg)
	if err != nil {
		log.Print(err)
	}
	count := 0
	bm := buffstreams.New(cfg)
	currentTime := time.Now()
	lastTime := currentTime
	address := buffstreams.FormatAddress("127.0.0.1", strconv.Itoa(5031))
	for {
		_, err := bm.WriteTo(address, msgBytes, true)
		if err != nil {
			log.Print("EEEEEERRRRROOOOOOOORRRRRRRRRRR")
			log.Print(err)
		}
		count = count + 1
		if lastTime.Second() != currentTime.Second() {
			lastTime = currentTime
			log.Printf(", %d", count)
			count = 0
		}
		currentTime = time.Now()
	}
}
コード例 #3
0
ファイル: test_server.go プロジェクト: ezbercih/buffstreams
func main() {
	cfg := buffstreams.BuffManagerConfig{
		MaxMessageSize: 2048,
		EnableLogging:  true,
	}

	bm := buffstreams.New(cfg)
	bm.StartListening(strconv.Itoa(5031), TestCallback)
	// Need to block until ctrl+c, but having trouble getting signal trapping to work on OSX...
	time.Sleep(time.Minute * 10)
}
コード例 #4
0
ファイル: test.go プロジェクト: ezbercih/buffstreams
// This is not a proper test, but it lets me benchmark how it
// performs on a raw level. Run this with the time command
func main() {
	cfg := buffstreams.BuffManagerConfig{
		MaxMessageSize: 256,
		EnableLogging:  true,
	}
	// 100 byte message
	name := "Stabby"
	date := time.Now().UnixNano()
	data := "This is an intenntionally long and rambling sentence to pad out the size of the message."
	msg := &message.Note{Name: &name, Date: &date, Comment: &data}
	msgBytes, err := proto.Marshal(msg)
	if err != nil {
		log.Print(err)
	}
	startingPort := 5031
	bm := buffstreams.New(cfg)
	bm.StartListening(strconv.Itoa(startingPort), TestCallback)

	for i := 0; i < 10; i++ {
		go func(n int, port string, bm *buffstreams.BuffManager) {
			address := buffstreams.FormatAddress("127.0.0.1", port)
			count := 0
			for {
				_, err := bm.WriteTo(address, msgBytes, true)
				//log.Printf("Wrote %d Bytes of %d + 2, error was: %s", written, len(msgBytes), err)
				if err != nil {
					log.Printf("Error %s", err)
				}
				count = count + 1
				log.Printf("%d - %d", n, count)
			}
		}(i, strconv.Itoa(startingPort), bm)
		//startingPort = startingPort + 1
	}
	time.Sleep(time.Minute * 10)
}