Skip to content

Instantly share code, notes, and snippets.

@Barbery
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Barbery/9a5d2caf0915f370acdd to your computer and use it in GitHub Desktop.
Save Barbery/9a5d2caf0915f370acdd to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
//for this question: http://www.v2ex.com/t/139818#reply98
func main() {
var sum, i int64
start := time.Now().UnixNano()
for i = 0; i <= 1000000000; i++ {
sum += i
}
fmt.Println(sum, float64(time.Now().UnixNano()-start)/1000000000.00)
}
//result:500000000500000000 0.8236045
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment