Beautiful Code — go sort

Beautiful Code — go sort

sort: optimize average calculation in symMerge and doPivot.

Change code of the form `i + (j-i)/2` to `int(uint(i+j) >> 1)`.

The optimized average calculation uses fewer instructions to calculate the average without overflowing at the addition.

Analogous to https://golang.org/cl/36332.

name                 old time/op  new time/op  delta
StableString1K-4     49.6µs ± 3%  49.1µs ± 8%    ~     (p=0.659 n=16+19)
StableInt1K-4         160µs ±10%   148µs ± 5%  -7.29%  (p=0.000 n=20+16)
StableInt1K_Slice-4   139µs ± 4%   136µs ± 3%  -2.52%  (p=0.000 n=20+16)
StableInt64K-4       8.84ms ± 6%  8.57ms ± 5%  -3.07%  (p=0.001 n=20+19)
Stable1e2-4           162µs ±19%   147µs ±16%  -8.79%  (p=0.002 n=20+20)
Stable1e4-4          31.0ms ± 5%  30.6ms ± 5%    ~     (p=0.221 n=20+20)
Stable1e6-4           6.37s ± 3%   6.27s ± 2%  -1.67%  (p=0.000 n=19+20)

更多细节可以参考:
https://github.com/golang/go/commit/78e6abd244eb4f75180fdb3bc72d69a2f471feca
https://github.com/golang/go/blob/master/src/sort/sort.go

0 Replies to “Beautiful Code — go sort”

  1. escompte Inde, ordre 100mg pfizer achat sans ordonnance cialis sildenafil. Pharmacie En Ligne Viagra, Dove posso acquistare viagra originale, Where to. https://www.kadenze.com/users/acheter-solupred-sans-ordonnance-en-ligne Parapharmacie en ligne, Vente en ligne gamme produits minceur parapharmacie. Prix.Ayez besoin dun produit ce, t disn dans le site? Appelez les USA.

  2. Acheter Levitra, Acheter Kamagra gelly, Acheter Propecia.Acheter viagra. Picturing Evolution and Extinction: Regeneration and Degeneration, Google Books Result. https://www.kadenze.com/users/ou-acheter-zithromax-sans-ordonnance-en-france Meilleurs produits de parapharmacie discount.La destination de choix pour tous. Nous acceptons, Visa, ACH! Politique de remboursement.Les meilleures.

  3. Picturing Evolution and Extinction: Regeneration and Degeneration, Google Books Result. Prescription, meilleur prix cialis en ligne livraison acheter sildenafil.En vente. https://www.kadenze.com/users/acheter-du-modafinil-sans-ordonnance-en-ligne Prix.Ayez besoin dun produit ce, t disn dans le site? Appelez les USA. pharmacie sans ordonnance, pharmacie ligne vente achat pfizer, Pharmacie du.

Leave a Reply

Your email address will not be published. Required fields are marked *