Exemple #1
0
func (stat *localStatist) Init(dir string, filename string, total int32) {
	mylog.GetLocalLogger().Init(dir, filename)
	stat.TotalRes = total

	stat.SendDataLen = 0
	stat.RecvDataLen = 0
	stat.SendBand = new(bandWidth)
	stat.RecvBand = new(bandWidth)

	stat.Delay = new(networkDelay)

}
Exemple #2
0
func (stat *localStatist) Start() {
	//On : %v, Total : %v, TotalLeave : %v, Open : %v, ResData : %vk
	time.Sleep(10 * time.Second)
	for {
		logBuffer := new(bytes.Buffer)
		var gcStatus debug.GCStats
		debug.ReadGCStats(&gcStatus)
		if len(gcStatus.Pause) > 0 {
			fmt.Printf("******GCTime:(%v:%v),GCNum:%v, GCPause:%v,GCPT:%v******\n",
				gcStatus.LastGC.Minute(),
				gcStatus.LastGC.Second(),
				gcStatus.NumGC,
				gcStatus.Pause[0],
				gcStatus.PauseTotal.Seconds())
		}
		time.Sleep(2 * time.Second)
		fmt.Fprintf(logBuffer, "%v %v %v %v %v %v\n",
			atomic.AddInt32(&stat.ResOnCount, 0),
			atomic.AddInt32(&stat.TotalRes, 0),
			atomic.AddInt32(&stat.LeaveTotalCount, 0),
			atomic.AddInt32(&stat.OpenResCount, 0),
			atomic.AddUint64(&stat.RecvDataLen, 0)/M1,
			atomic.AddUint64(&stat.SendDataLen, 0)/M1)

		mylog.GetLocalLogger().Write(logBuffer.String())

		consoleBuffer := new(bytes.Buffer)
		fmt.Fprintf(consoleBuffer, "On:%v,Total:%v,TotalLeave:%v,Open:%v,RecvBand:%.2fmps,SendBand:%.2fmps,Delay:%.2fms\n",
			atomic.AddInt32(&stat.ResOnCount, 0),
			atomic.AddInt32(&stat.TotalRes, 0),
			atomic.AddInt32(&stat.LeaveTotalCount, 0),
			atomic.AddInt32(&stat.OpenResCount, 0),
			(stat.RecvBand.getBandWidth()*8)/M1,
			(stat.SendBand.getBandWidth()*8)/M1,
			(stat.Delay.getDelay()/1000000)/float64(stat.ResOnCount))
		curTime := time.Now()
		curBuffer := new(bytes.Buffer)
		fmt.Fprintf(curBuffer, "%02d:%02d:%02d",
			curTime.Hour(),
			curTime.Minute(),
			curTime.Second())
		fmt.Println(curBuffer.String(), consoleBuffer.String())
		time.Sleep(10 * time.Second)
		debug.FreeOSMemory()
	}

}