BewareMyPower commented on PR #1437:
URL:
https://github.com/apache/pulsar-client-go/pull/1437#issuecomment-3544847512
Without the lock:
```
477056558 elapsed time: 79.822416ms avg: 7 ns
```
```go
wg.Add(1)
//wg.Add(2)
//lock := sync.Mutex{}
go func() {
start := time.Now()
sum := int64(0)
const n = 10000000
for i := 0; i < n; i++ {
partition := rand.Int()
//lock.Lock()
sum = sum + int64(slice[partition%len(slice)])
//lock.Unlock()
}
finished := time.Since(start)
fmt.Println(sum, " elapsed time:", finished, " avg: ",
finished.Nanoseconds()/n, " ns")
wg.Done()
}()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]