talks

git clone git://code.dwrz.net/talks
Log | Files | Refs

main.go (517B)


      1 package main
      2 
      3 import (
      4 	"fmt"
      5 	"time"
      6 )
      7 
      8 var cities = []string{
      9 	"Chicago",
     10 	"Dallas",
     11 	"Houston",
     12 	"Los Angeles",
     13 	"New York",
     14 	"Philadelphia",
     15 	"Phoenix",
     16 	"San Antonio",
     17 	"San Diego",
     18 	"San Jose",
     19 }
     20 
     21 func main() {
     22 	now := time.Now()
     23 
     24 	printTemperatures(cities)
     25 
     26 	fmt.Printf(
     27 		"\nTook %v to get temperatures sequentially.\n\n",
     28 		time.Since(now),
     29 	)
     30 
     31 	// Reset the timer.
     32 	now = time.Now()
     33 
     34 	printTemperaturesAsync(cities)
     35 
     36 	fmt.Printf(
     37 		"\nTook %v to get temperatures concurrently.\n\n",
     38 		time.Since(now),
     39 	)
     40 }