예제 #1
0
파일: main.go 프로젝트: vdt/matching_engine
func doPerf(log bool) {
	flag.Parse()
	orderData := getData()
	orderCount := fstrconv.Itoa64Comma(int64(len(orderData)))
	if log {
		println(orderCount, "OrderNodes Built")
	}
	in := make(chan *msg.Message, len(orderData))
	out := make(chan *msg.Message, len(orderData))
	m := matcher.NewMatcher(*delDelay * 2)
	m.Config("Perf Matcher", in, out)
	go m.Run()
	startProfile()
	defer endProfile()
	start := time.Now().UnixNano()
	for i := range orderData {
		in <- &orderData[i]
	}
	// TODO this is only testing how fast we can push messages into the matcher, not useful
	if log {
		println("Buffer Writes: ", len(out))
		total := time.Now().UnixNano() - start
		println("Nanos\t", fstrconv.Itoa64Comma(total))
		println("Micros\t", fstrconv.Itoa64Comma(total/1000))
		println("Millis\t", fstrconv.Itoa64Comma(total/(1000*1000)))
		println("Seconds\t", fstrconv.Itoa64Comma(total/(1000*1000*1000)))
	}
}
예제 #2
0
func multiThreaded(log bool, data []msg.Message, in, out coordinator.MsgReaderWriter) {
	mchr := matcher.NewMatcher(*delDelay * 2)
	mchr.Config("Perf Matcher", in, out)
	go run(mchr)
	go write(in, data)
	// Read all messages coming out of the matching engine
	read(out)
}
예제 #3
0
func singleThreaded(log bool, data []msg.Message) {
	inout := coordinator.NewNoopReaderWriter()
	mchr := matcher.NewMatcher(*delDelay * 2)
	mchr.Config("Perf Matcher", inout, inout)
	for i := range data {
		mchr.Submit(&data[i])
	}
}
func main() {
	flag.Parse()
	orderNum := 10 * 1000 * 1000
	sells := mkSells(orderNum, 1000, 1500)
	buys := mkBuys(orderNum, 1000, 1500)
	m := matcher.NewMatcher(stockId)
	startProfile()
	defer endProfile()
	start := time.Now().UnixNano()
	for i := 0; i < orderNum; i++ {
		m.AddBuy(buys[i])
		m.AddSell(sells[i])
	}
	total := time.Now().UnixNano() - start
	println(total)
}
예제 #5
0
파일: main.go 프로젝트: vdt/matching_engine
func main() {
	pwd, err := os.Getwd()
	if err != nil {
		println(err.Error())
		return
	}
	// Create matching engine + client
	clientToServer := q.NewSimpleQ("Client To Server")
	serverToClient := q.NewSimpleQ("Server To Client")
	// Matching Engine
	m := matcher.NewMatcher(100)
	var traderClient *client.C
	traderClient, commMaker = client.NewClient()
	coordinator.InMemory(serverToClient, clientToServer, traderClient, clientOriginId, "Client.........", true)
	coordinator.InMemory(clientToServer, serverToClient, m, serverOriginId, "Matching Engine", true)
	http.Handle("/wsconn", websocket.Handler(handleTrader))
	http.Handle("/", http.FileServer(http.Dir(pwd+"/html/")))
	if err := http.ListenAndServe("127.0.0.1:8081", nil); err != nil {
		println(err.Error())
	}
}