func main() { workers := []gop.Worker{ &MyWorker{"first", 200 * time.Millisecond}, &MyWorker{"second", 300 * time.Millisecond}, &MyWorker{"third", 1000 * time.Millisecond}, } start := time.Now() g := gop.New(500 * time.Millisecond) results := g.Run(workers) fmt.Printf("Done, got %d results\n", len(results)) fmt.Printf("Total: %s\n", time.Now().Sub(start)) time.Sleep(3 * time.Second) }
func main() { workers := []gop.Worker{ &MyWorker{"first"}, &MyWorker{"second"}, &MyWorker{"third"}, } start := time.Now() g := gop.New(5 * time.Second) results := g.Run(workers) for _, result := range results { r := result.(string) fmt.Println(r) } fmt.Printf("Done, got %d results\n", len(results)) fmt.Printf("Total: %s\n", time.Now().Sub(start)) }
func main() { workers := []gop.Worker{ &MyWorker{"http://google.com"}, &MyWorker{"http://yahoo.com"}, &MyWorker{"http://baidu.com"}, } start := time.Now() g := gop.New(10000 * time.Millisecond) results := g.Run(workers) for _, result := range results { r := result.(MyResult) fmt.Println(r.status) } fmt.Printf("Done, got %d results\n", len(results)) fmt.Printf("Total %s\n", time.Now().Sub(start)) }