Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Study and understand how the fetchall program from the reference Reference below. Execute it for the following top 10 search engines (you will pass them
Study and understand how the fetchall program from the reference Reference below.
Execute it for the following top 10 search engines (you will pass them all to the program at the same time as command-line arguments) and report their parallel and individual fetch times in a bar graph: Google, Bing, Yahoo, Baidu, Yandex, DuckDuckGo, Ask.com, Ecosia, Aol.com, Internet Archive Make sure that you repeated the above experiment 10 times and averaged the results before reporting them. Next, modify the fetchall program so that it runs sequentially. For this task, you will initially need to remove the go keyword in line 17; however, this will cause the program to hang. Explain why it hangs, fix the hanging issue, and report how you fixed it. Share your modified code for the sequential version and report again in another bar graph the sequential fetch time together with the individual ones. Report the speed-up (sequential fetch time divided by the parallel fetch time), and let us know which search engine is fetched the fastest in your tests! 1.6 Fetching URLs Concurrently One of the most interesting and novel aspects of G0 is its support for concurrent programming. This is a large topic, to which Chapter 8 and Chapter 9 are devoted, so for now we'll give you just a taste of Go's main concurrency mechanisms, goroutines and channels. The next program, fetchall, does the same fetch of a URL's contents as the previous example, but it fetches many URLs, all concurrently, so that the process will take no longer than the longest fetch rather than the sum of all the fetch times. This version of fetchall discards the responses but reports the size and elapsed time for each one: gopl.io/ch1/fetchall I/ Fetchall fetches URLs in parallel and reports their times and sizes. package main import ( "fmt" "io" "io/ioutil" "net/http" "os" "time" ) func main() \{ start := time.Now() ch := make(chan string) for, , url := range os.Args[1:] \{ \}o fetch(url, ch) // start a goroutine for range os.Args[1:] \{ fmt.Println(Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started