1
0
mirror of https://github.com/golang/go synced 2024-10-03 08:11:27 -06:00
Commit Graph

7 Commits

Author SHA1 Message Date
Florin Patan
0ca49135a0 sort: fixed small typo in comments
There was a small typo in the comment before the Stable function.

Change-Id: Ia6fa5272aa7869124a637d2eeda81c4f35ef46c8
Reviewed-on: https://go-review.googlesource.com/4201
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-08 23:38:50 +00:00
Martin Möhrmann
2c7c727c1c sort: reduce number of comparisons needed by medianOfThree
For some cases we can ensure the correct order of elements in two
instead of three comparisons. It is unnecessary to compare m0 and
m1 again if m2 and m1 are not swapped.

benchmark                   old ns/op      new ns/op      delta
BenchmarkSortString1K       302721         299590         -1.03%
BenchmarkSortInt1K          124055         123215         -0.68%
BenchmarkSortInt64K         12291522       12203402       -0.72%
BenchmarkSort1e2            58027          57111          -1.58%
BenchmarkSort1e4            12426805       12341761       -0.68%
BenchmarkSort1e6            1966250030     1960557883     -0.29%

Change-Id: I2b17ff8dee310ec9ab92a6f569a95932538768a9
Reviewed-on: https://go-review.googlesource.com/2614
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-01-13 19:37:02 +00:00
Martin Möhrmann
e5864cd939 sort: optimize symMerge performance for blocks with one element
Use direct binary insertion instead of recursive calls to symMerge
when one of the blocks has only one element.

benchmark                   old ns/op      new ns/op      delta
BenchmarkStableString1K     421999         397629         -5.77%
BenchmarkStableInt1K        123422         120592         -2.29%
BenchmarkStableInt64K       9629094        9620200        -0.09%
BenchmarkStable1e2          123089         120209         -2.34%
BenchmarkStable1e4          39505228       36870029       -6.67%
BenchmarkStable1e6          8196612367     7630840157     -6.90%

Change-Id: I49905a909e8595cfa05920ccf9aa00a8f3036110
Reviewed-on: https://go-review.googlesource.com/2219
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-01-06 23:30:46 +00:00
Martin Möhrmann
76cc881ef0 sort: simplify rotate and reduce calls to it
Move the checks for empty rotate changes
from the beginning of rotate to the callers.

Remove additional variable p used instead of existing m with same value.

Remove special casing of equal ranges (i==j) to exit early as no
work is saved vs checking (i!=j) and  making a single
swapRange call if this is false.

benchmark                   old ns/op      new ns/op      delta
BenchmarkStableString1K     417195         425218         +1.92%
BenchmarkStableInt1K        126661         124498         -1.71%
BenchmarkStableInt64K       10365014       10417438       +0.51%
BenchmarkStable1e2          132151         130648         -1.14%
BenchmarkStable1e4          42027428       40812649       -2.89%
BenchmarkStable1e6          8524772364     8430192391     -1.11%

Change-Id: Ia7642e9d31408496970c700f5843d53cc3ebe817
Reviewed-on: https://go-review.googlesource.com/2100
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-23 23:21:04 +00:00
Josh Bleecher Snyder
2a617d46f3 sort: reduce leaf calls in Stable
Move the symMerge recursion stopping condition
from the beginning of symMerge to the callers.

This halves the number of calls to symMerge
while running 'go test sort'.

benchmark                   old ns/op      new ns/op      delta
BenchmarkStable1e6          8358117060     7954143849     -4.83%
BenchmarkStable1e4          40116117       38583285       -3.82%
BenchmarkStableInt1K        119150         115182         -3.33%
BenchmarkStableInt64K       9799845        9515475        -2.90%
BenchmarkStableString1K     388901         393516         +1.19%
BenchmarkStable1e2          124917         123618         -1.04%

Change-Id: I7ba2ca277f213b076fe6830e1139edb47ac53800
Reviewed-on: https://go-review.googlesource.com/1820
Reviewed-by: Robert Griesemer <gri@golang.org>
2014-12-22 21:17:43 +00:00
Josh Bleecher Snyder
6ceb60444d sort: deduplicate inner loop of Stable
benchmark                   old ns/op      new ns/op      delta
BenchmarkStableInt1K        117212         116287         -0.79%
BenchmarkStableInt64K       9632002        9587872        -0.46%
BenchmarkStable1e4          40044309       39865644       -0.45%
BenchmarkStable1e2          126985         126456         -0.42%
BenchmarkStableString1K     389774         391052         +0.33%
BenchmarkStable1e6          8183202516     8157693442     -0.31%

Change-Id: I14e518ad49ecce3d1fc2b056e1acd5e5a2de8144
Reviewed-on: https://go-review.googlesource.com/1821
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-19 18:26:26 +00:00
Russ Cox
c007ce824d build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
2014-09-08 00:08:51 -04:00