Esempio n. 1
0
// set command
func setValue(c *client.GhostClient, args []string) error {
	if len(args) != 2 {
		return errors.New(fmt.Sprintf("wrong number of arguments to SET: need 2, get %d", len(args)))
	}

	c.Set(args[0], args[1])
	return nil
}
Esempio n. 2
0
func populateTestDataServer(c *client.GhostClient, keys, vals []string) {
	var wg sync.WaitGroup
	for i := 0; i < requests; i++ {
		wg.Add(1)
		go func(i int) {
			c.Set(keys[i], vals[i])
			wg.Done()
		}(i)
	}
	wg.Wait()
	return
}
Esempio n. 3
0
func benchmarkServerSet(c *client.GhostClient) result {
	var wg sync.WaitGroup
	keys, vals := initTestData("set", requests, size, keyrange)

	start := time.Now()

	for i := 0; i < requests; i++ {
		wg.Add(1)
		go func(keys, vals []string, i int) {
			c.Set(keys[i], vals[i])
			wg.Done()
		}(keys, vals, i)
	}
	wg.Wait()

	latency := time.Since(start)

	return result{
		totTime: latency,
		reqSec:  float64(requests) / latency.Seconds(),
	}
}