func (bA *Benchmark) Final() {
	//Wait for all the go routines to complete
	bA.waitGroup.Wait()

	successRatio := float64(bA.successCounter) * float64(100) / float64(bA.requestCounter)
	errorRatio := float64(bA.errorCounter) * float64(100) / float64(bA.requestCounter)

	//Req completion will be printed inside this infinite for loop, as well as the app would wait
	fmt.Println(
		"\n========================= Benchmark stats =========================\n",
		"\nDone               :", time.Now(),
		"\nTime to complete   :", time.Since(bA.benchStart),
		"\nTotal requests     :", bA.TotalRequests,
		"\nRequests completed :", bA.requestCounter,
		"\nSuccess            :", bA.successCounter, "("+strconv.FormatFloat(successRatio, 'f', -1, 64)+"%)",
		"\nErrors             :", bA.errorCounter, "("+strconv.FormatFloat(errorRatio, 'f', -1, 64)+"%)",
	)

	if bA.successCounter > 0 {
		fmt.Println(
			"\nAverage time per successful request :", time.Nanosecond*time.Duration(bA.successRequestTimer)/time.Duration(bA.successCounter),
			"\nFastest                             :", time.Duration(time.Nanosecond*time.Duration(bA.successMinReqTime)),
			"\nSlowest                             :", time.Duration(time.Nanosecond*time.Duration(bA.successMaxReqTime)),
		)
	}

	if bA.errorCounter > 0 {
		fmt.Println(
			"\nAverage time per failed request :", time.Nanosecond*time.Duration(bA.errorRequestTimer)/time.Duration(bA.errorCounter),
			"\nFastest                         :", time.Duration(time.Nanosecond*time.Duration(bA.errorMinReqTime)),
			"\nSlowest                         :", time.Duration(time.Nanosecond*time.Duration(bA.errorMaxReqTime)),
		)
	}

	if len(bA.errors) > 0 {
		println("\n\nError messages (" + strconv.Itoa(len(bA.errors)) + ")")
		idx := 1
		for _, item := range bA.errors {
			println("\n "+strconv.Itoa(idx)+".", item.Message)
			println("  Occurrences:", item.Count)
			idx++
		}
	}
}
//Final prints all the statistics of the benchmark
//The input to Final() is the time when you start the benchmark
Final prints all the statistics of the benchmark
The input to Final() is the time when you start the benchmark
// Final prints all the statistics of the benchmark // The input to Final () is the time when you start the benchmark
func (bA *Benchmark) Final() {
	bA.waitGroup.Wait()
	successRatio := float64(bA.successCounter) * float64(100) / float64(bA.requestCounter)
	errorRatio := float64(bA.errorCounter) * float64(100) / float64(bA.requestCounter)
	fmt.Println(
		"\n========================= Benchmark stats =========================\n",
		"\nDone               :", time.Now(),
		"\nTime to complete   :", time.Since(bA.benchStart),
		"\nTotal requests     :", bA.TotalRequests,
		"\nRequests completed :", bA.requestCounter,
		"\nSuccess            :", bA.successCounter, "("+strconv.FormatFloat(successRatio, 'f', -1, 64)+"%)",
		"\nErrors             :", bA.errorCounter, "("+strconv.FormatFloat(errorRatio, 'f', -1, 64)+"%)",
	)
	if bA.successCounter > 0 {
		fmt.Println(
			"\nAverage time per successful request :", time.Nanosecond*time.Duration(bA.successRequestTimer)/time.Duration(bA.successCounter),
			"\nFastest                             :", time.Duration(time.Nanosecond*time.Duration(bA.successMinReqTime)),
			"\nSlowest                             :", time.Duration(time.Nanosecond*time.Duration(bA.successMaxReqTime)),
		)
	}
	if bA.errorCounter > 0 {
		fmt.Println(
			"\nAverage time per failed request :", time.Nanosecond*time.Duration(bA.errorRequestTimer)/time.Duration(bA.errorCounter),
			"\nFastest                         :", time.Duration(time.Nanosecond*time.Duration(bA.errorMinReqTime)),
			"\nSlowest                         :", time.Duration(time.Nanosecond*time.Duration(bA.errorMaxReqTime)),
		)
	}
	if len(bA.errors) > 0 {
		println("\n\nError messages (" + strconv.Itoa(len(bA.errors)) + ")")
		idx := 1
		for _, item := range bA.errors {
			println("\n "+strconv.Itoa(idx)+".", item.Message)
			println("  Occurrences:", item.Count)
			idx++
		}
	}
}
func ( bA * Benchmark ) Final ( ) { bA . waitGroup . Wait ( ) successRatio := float64 ( bA . successCounter ) * float64 ( 100 ) / float64 ( bA . requestCounter ) errorRatio := float64 ( bA . errorCounter ) * float64 ( 100 ) / float64 ( bA . requestCounter ) fmt . Println ( " \n \n " , " \n " , time . Now ( ) , " \n " , time . Since ( bA . benchStart ) , " \n " , bA . TotalRequests , " \n " , bA . requestCounter , " \n " , bA . successCounter , " " + strconv . FormatFloat ( successRatio , 'f' , - 1 , 64 ) + " " , " \n " , bA . errorCounter , " " + strconv . FormatFloat ( errorRatio , 'f' , - 1 , 64 ) + " " , ) if bA . successCounter > 0 { fmt . Println ( " \n " , time . Nanosecond * time . Duration ( bA . successRequestTimer ) / time . Duration ( bA . successCounter ) , " \n " , time . Duration ( time . Nanosecond * time . Duration ( bA . successMinReqTime ) ) , " \n " , time . Duration ( time . Nanosecond * time . Duration ( bA . successMaxReqTime ) ) , ) } if bA . errorCounter > 0 { fmt . Println ( " \n " , time . Nanosecond * time . Duration ( bA . errorRequestTimer ) / time . Duration ( bA . errorCounter ) , " \n " , time . Duration ( time . Nanosecond * time . Duration ( bA . errorMinReqTime ) ) , " \n " , time . Duration ( time . Nanosecond * time . Duration ( bA . errorMaxReqTime ) ) , ) } if len ( bA . errors ) > 0 { println ( " \n \n " + strconv . Itoa ( len ( bA . errors ) ) + " " ) idx := 1 for _ , item := range bA . errors { println ( " \n " + strconv . Itoa ( idx ) + " " , item . Message ) println ( " " , item . Count ) idx ++ } } }
Final prints all the statistics of the benchmark
The input to Final() is the time when you start the benchmark
Final prints all the statistics of the benchmark The input to Final () is the time when you start the benchmark
//Wait for all the go routines to complete //Req completion will be printed inside this infinite for loop, as well as the app would wait