Grokking Advanced Go
Vote

0% completed

​

Iterator Adapters

A report needs the first 3 paid orders from a list of 100,000 orders, and half of those orders are paid. Code that builds a slice of paid orders and then takes the first 3 calls its paid check 100,000 times and allocates memory 26 times. The same logic written with iterators calls the paid check 5 times and allocates memory 3 times.

A program further down this page measured both versions on one machine. The difference comes from when each step runs. The slice code finishes each step before the next one begins

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content