func pqsDequeue(msgCount int64, q *spscq.PointerQ, done chan bool) { runtime.LockOSThread() start := time.Now().UnixNano() sum := int64(0) checksum := int64(0) var v unsafe.Pointer for i := int64(1); i <= msgCount; i++ { v = q.ReadSingle() for v == nil { v = q.ReadSingle() } pv := int64(uintptr(v)) sum += pv checksum += i if pv != i { print(fmt.Sprintf("Bad message. Expected %d, found %d (found-expected = %d)", pv, i, pv-i)) } } nanos := time.Now().UnixNano() - start printSummary(msgCount, nanos, q.FailedWrites(), q.FailedReads(), "pqs") expect(sum, checksum) done <- true }
func pqarlDequeue(msgCount int64, q *spscq.PointerQ, batchSize int64, done chan bool) { runtime.LockOSThread() start := time.Now().UnixNano() sum := int64(0) checksum := int64(0) t := int64(1) var buffer []unsafe.Pointer for t < msgCount { buffer = q.AcquireRead(batchSize) for buffer == nil { buffer = q.AcquireRead(batchSize) } for i := range buffer { t++ sum += int64(uintptr(buffer[i])) checksum += t } q.ReleaseReadLazy() } nanos := time.Now().UnixNano() - start printSummary(msgCount, nanos, q.FailedWrites(), q.FailedReads(), "pqarl") expect(sum, checksum) done <- true }
func pqrwDequeue(msgCount int64, q *spscq.PointerQ, batchSize int64, done chan bool) { runtime.LockOSThread() start := time.Now().UnixNano() sum := int64(0) checksum := int64(0) t := int64(1) buffer := make([]unsafe.Pointer, batchSize) for t < msgCount { if batchSize > msgCount-t { buffer = buffer[:msgCount-t] } for r := false; r == false; r = q.Read(buffer) { } for i := range buffer { t++ sum += int64(uintptr(buffer[i])) checksum += t } } nanos := time.Now().UnixNano() - start printSummary(msgCount, nanos, q.FailedWrites(), q.FailedReads(), "pqrw") expect(sum, checksum) done <- true }