Fengzdadi opened a new pull request, #87:
URL: https://github.com/apache/datasketches-go/pull/87

   ## Summary
   
   Minor optimization to `deserializeCouponList()` in `hll/coupon_list.go` - 
pre-compute the offset instead of calculating `listIntArrStart + it*4` in each 
iteration.
   
   ## Related Issue
   
   Closes #86 
   
   ## Changes
   
   ```diff
   - for it := 0; it < couponCount; it++ {
   -     list.couponIntArr[it] = 
int(binary.LittleEndian.Uint32(byteArray[listIntArrStart+it*4 : 
listIntArrStart+it*4+4]))
   - }
   + base := listIntArrStart
   + for it := 0; it < couponCount; it++ {
   +     list.couponIntArr[it] = 
int(binary.LittleEndian.Uint32(byteArray[base:]))
   +     base += 4
   + }
   ```
   
   ## Benchmark Results
   
   | Method | 8 items | 32 items | 128 items | 1024 items |
   |--------|---------|----------|-----------|------------|
   | Before | 27.6 ns | 75.4 ns | 270 ns | 2153 ns |
   | After | 26.8 ns | 69.9 ns | 253 ns | 2000 ns |
   
   ~7% improvement by replacing multiplication with addition per iteration.
   
   ## Testing
   
   All existing tests pass:
   ```
   go test ./hll/
   ```
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to