Esempio n. 1
0
func main() {
	nTotal := flag.Uint64("n", math.MaxUint64, "number of times to perform a read and write operation")
	initialProcess := flag.String("initial", "", "Process to ask for the initial view")
	retryProcess := flag.String("retry", "", "Process to ask for a newer view")
	flag.Parse()

	freestoreClient, err := client.New(getInitialViewFunc(*initialProcess), getFurtherViewsFunc(*retryProcess))
	if err != nil {
		log.Fatalln("FATAL:", err)
	}

	var finalValue interface{}
	for i := uint64(0); i < *nTotal; i++ {
		startRead := time.Now()
		finalValue, err = freestoreClient.Read()
		endRead := time.Now()
		if err != nil {
			log.Fatalln(err)
		}

		startWrite := time.Now()
		err = freestoreClient.Write(finalValue)
		endWrite := time.Now()
		if err != nil {
			log.Fatalln(err)
		}

		if i%1000 == 0 {
			fmt.Printf("%v: Read %v (%v)-> Write (%v)\n", i, finalValue, endRead.Sub(startRead), endWrite.Sub(startWrite))
		} else {
			fmt.Printf(".")
		}
	}
}
Esempio n. 2
0
func main() {
	flag.Parse()

	var err error
	freestoreClient, err = client.New(getInitialView, getFurtherViews)
	if err != nil {
		log.Fatalln("FATAL:", err)
	}

	stopChan = time.After(*totalDuration)

	if *measureLatency {
		latency()
	} else if *measureThroughput {
		throughput()
	} else {
		latencyAndThroughput()
	}
}