Exemple #1
0
func lowerWindow(c1 chan string, cycles int64) {
	C.init_perfcounters(1, 0)
	timeStart := C.ulonglong(C.get_cyclecount())
	for {
		timeElapsed := C.ulonglong(C.get_cyclecount()) - timeStart
		if timeElapsed > C.ulonglong(cycles) {
			c1 <- "ENTER WINDOW\n"
			break
		}
	}
}
Exemple #2
0
func waitTimer(cycles int64, f *os.File) int {
	// init counters:
	C.init_perfcounters(1, 0)
	//fmt.Printf("cyles to wait: %d\n", cycles)
	timeStart := C.ulonglong(C.get_cyclecount())
	timeElapsed := C.ulonglong(0)
	for {
		timeElapsed = C.ulonglong(C.get_cyclecount()) - timeStart
		if timeElapsed > C.ulonglong(cycles) {
			writeMessage(f, fmt.Sprintf("%27s", "COMPLETE"))
			break
		}
	}
	return int(timeElapsed)
}
Exemple #3
0
func main() {
	// init counters:
	C.init_perfcounters(1, 0)

	// measure the counting overhead:
	overhead := C.get_cyclecount()
	overhead = C.get_cyclecount() - overhead

	sleeptime := time.Duration(1) * time.Second
	t := C.get_cyclecount()
	time.Sleep(sleeptime) //delay
	//fmt.Println("test data to benchmark Println function call")

	t = C.get_cyclecount() - t

	fmt.Printf("Sleeping took exactly %d cycles and overhead of get_cyclecount() was %d cycles\n", t-overhead, overhead)
}