// change performance results into string arrays(for tabular format printing) and profileStruct (to print single performance result)
change performance results into string arrays(for tabular format printing) and profileStruct (to print single performance result)
// change performance results into string arrays ( for tabular format printing ) and profileStruct ( to print single performance result )
func performanceResultsToStringArrays(results []models.PerformanceResult) ([][]string, []resultStruct) {
	var data [][]string
	var expendedData []resultStruct
	for _, result := range results {
		serviceMesh := "No Mesh"
		p50 := ""
		p99_9 := ""
		var P50, P90, P99 float64
		if result.Mesh != "" {
			serviceMesh = result.Mesh
		}
		qps := fmt.Sprintf("%d", int(result.RunnerResults.QPS))
		duration := result.RunnerResults.RequestedDuration
		if len(result.RunnerResults.DurationHistogram.Percentiles) > 0 {
			p50 = fmt.Sprintf("%.8f", result.RunnerResults.DurationHistogram.Percentiles[0].Value)
			p99_9 = fmt.Sprintf("%.8f", result.RunnerResults.DurationHistogram.Percentiles[len(result.RunnerResults.DurationHistogram.Percentiles)-1].Value)
		}
		startTime := result.TestStartTime.Format("2006-01-02 15:04:05")
		data = append(data, []string{result.Name, serviceMesh, qps, duration, p50, p99_9, startTime})
		if len(result.RunnerResults.DurationHistogram.Percentiles) > 3 {
			P50 = result.RunnerResults.DurationHistogram.Percentiles[0].Value
			P90 = result.RunnerResults.DurationHistogram.Percentiles[2].Value
			P99 = result.RunnerResults.DurationHistogram.Percentiles[3].Value
		}
		a := resultStruct{
			Name:     result.Name,
			UserID:   result.UserID,
			URL:      result.RunnerResults.URL,
			QPS:      int(result.RunnerResults.QPS),
			Duration: result.RunnerResults.RequestedDuration,
			LatenciesMs: &models.LatenciesMs{
				Average: result.RunnerResults.DurationHistogram.Average,
				Max:     result.RunnerResults.DurationHistogram.Max,
				Min:     result.RunnerResults.DurationHistogram.Min,
				P50:     P50,
				P90:     P90,
				P99:     P99,
			},
			StartTime:     result.TestStartTime,
			MesheryID:     result.MesheryID,
			LoadGenerator: result.RunnerResults.LoadGenerator,
		}
		expendedData = append(expendedData, a)
	}
	return data, expendedData
}
func performanceResultsToStringArrays ( results [ ] models . PerformanceResult ) ( [ ] [ ] string , [ ] resultStruct ) { var data [ ] [ ] string var expendedData [ ] resultStruct for _ , result := range results { serviceMesh := " " p50 := " " p99_9 := " " var P50 , P90 , P99 float64 if result . Mesh != " " { serviceMesh = result . Mesh } qps := fmt . Sprintf ( " " , int ( result . RunnerResults . QPS ) ) duration := result . RunnerResults . RequestedDuration if len ( result . RunnerResults . DurationHistogram . Percentiles ) > 0 { p50 = fmt . Sprintf ( " " , result . RunnerResults . DurationHistogram . Percentiles [ 0 ] . Value ) p99_9 = fmt . Sprintf ( " " , result . RunnerResults . DurationHistogram . Percentiles [ len ( result . RunnerResults . DurationHistogram . Percentiles ) - 1 ] . Value ) } startTime := result . TestStartTime . Format ( " " ) data = append ( data , [ ] string { result . Name , serviceMesh , qps , duration , p50 , p99_9 , startTime } ) if len ( result . RunnerResults . DurationHistogram . Percentiles ) > 3 { P50 = result . RunnerResults . DurationHistogram . Percentiles [ 0 ] . Value P90 = result . RunnerResults . DurationHistogram . Percentiles [ 2 ] . Value P99 = result . RunnerResults . DurationHistogram . Percentiles [ 3 ] . Value } a := resultStruct { Name : result . Name , UserID : result . UserID , URL : result . RunnerResults . URL , QPS : int ( result . RunnerResults . QPS ) , Duration : result . RunnerResults . RequestedDuration , LatenciesMs : & models . LatenciesMs { Average : result . RunnerResults . DurationHistogram . Average , Max : result . RunnerResults . DurationHistogram . Max , Min : result . RunnerResults . DurationHistogram . Min , P50 : P50 , P90 : P90 , P99 : P99 , } , StartTime : result . TestStartTime , MesheryID : result . MesheryID , LoadGenerator : result . RunnerResults . LoadGenerator , } expendedData = append ( expendedData , a ) } return data , expendedData }
change performance results into string arrays(for tabular format printing) and profileStruct (to print single performance result)
change performance results into string arrays ( for tabular format printing ) and profileStruct ( to print single performance result )
// append data for single profile // append data for extended output