func writeConcurrent(cMap concurrentmap.ConcurrentMap, threads int, threadID int, done chan int64) { start := time.Now().UnixNano() numWrites := numberOfTests / threads for i := numWrites * threadID; i < numWrites*(threadID+1); i++ { s := strconv.Itoa(i) cMap.Put(s, s) } end := time.Now().UnixNano() done <- end - start return }
func mapReadTestSeries(cMap concurrentmap.ConcurrentMap) int { s1 := rand.NewSource(time.Now().UnixNano()) rng := rand.New(s1) notFound := 0 for i := 0; i < numberOfTests; i++ { key := strconv.Itoa(rng.Intn(numberOfTests)) val, e := cMap.Get(key) if val != key { fmt.Println("Key/Val Mismatch:", key, val) } if !e { notFound++ } } return notFound }
func readConcurrent(cMap concurrentmap.ConcurrentMap, threadID int, numReadThreads int, done chan int64) { start := time.Now().UnixNano() s1 := rand.NewSource(time.Now().UnixNano() * int64(threadID)) rng := rand.New(s1) notFound := 0 for i := 0; i < numberOfTests/numReadThreads; i++ { key := strconv.Itoa(rng.Intn(numberOfTests)) _, e := cMap.Get(key) if !e { notFound++ } } end := time.Now().UnixNano() done <- end - start return }