Skip to content

Instantly share code, notes, and snippets.

@sh0seo
Created March 27, 2019 16:00
Show Gist options
  • Select an option

  • Save sh0seo/ab98b303de332eabbb3fd8ac9973b1a7 to your computer and use it in GitHub Desktop.

Select an option

Save sh0seo/ab98b303de332eabbb3fd8ac9973b1a7 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/rand"
"sort"
"time"
)
func main() {
fmt.Println("Starting")
const x = 1000000
const y = x * 10
var s [y]float64
s1 := rand.NewSource(time.Now().UnixNano())
r1 := rand.New(s1)
start1 := time.Now()
for i := 0; i < y; i++ {
s[i] = r1.Float64()
}
end1 := time.Since(start1)
ss := s[:]
start2 := time.Now()
sort.Float64s(ss)
end2 := time.Since(start2)
fmt.Println(end1)
fmt.Println(end2)
fmt.Println("Number: ", ss[x])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment