Last active
May 20, 2019 03:20
-
-
Save suminb/83d19147feb92efd50bfc6aa1e7ea1be to your computer and use it in GitHub Desktop.
Go sort performance test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"math/rand" | |
"sort" | |
"testing" | |
) | |
var n = 600000000 | |
var seq = make([]int, n) | |
func TestRandomSeq(t *testing.T) { | |
for i := 0; i < n; i++ { | |
seq[i] = rand.Int() | |
} | |
} | |
func TestSort(t *testing.T) { | |
sort.Ints(seq) | |
} | |
/** | |
Sorting 600,000,000 random integers | |
On MacBook Pro (Retina, 15-inch, Mid 2015), 2.8 GHz Intel Core i7, 16 GB 1600 MHz DDR3 | |
$ go test -v sort_test.go | |
=== RUN TestRandomSeq | |
--- PASS: TestRandomSeq (13.52s) | |
=== RUN TestSort | |
--- PASS: TestSort (164.81s) | |
PASS | |
ok command-line-arguments 178.820s | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorting 100,000,000 random integers