hi,
I recently wanted to get the juice out of some programs.
A queue consumer that transforms inputs over many routines,
then aggregates the results to re order them.
The order is defined by the input order.
There was many variations written around it,
using a map, a slice, a regular heap, and finally,
a specialized heap (hand written).
Slice was best for its simplicity, regular heap made
with the package `container/heap` was not as good as expected.
The specialized heap was the best for performance,
but having this added complexity for only one small
library of ~100LOC did not seem a good idea.
So I wrote a template, included and rewrote the tests from
`container/heap`, et voilà, it makes sense.
It is tested, re usable, and made for perf.
Then you run (or add it via //go:gen..)
- "U => -, T => -, Heap=>MinIntHeap , MinIntHeap:U=>int, MinIntHeap:T=> minInt"
It generates for you a Heap that takes in input regular ints, output regular ints, but internally stores them as minInt.
So does it do any good ?
(I hope i have not made a mistake writing the comparison benchmarks, i would not like to criticize the core language implementation in such fashion...)
Notes:
1/ I have to say i was surprised to not find an existing similar project using
genny (a more popular code generator), did i miss something ?
Clément