results/summary.go
func (t *TabularResults) Tabulate(results []ResultSet) []Row {

	var rows []Row
	startTime := time.Unix(0, 0)

	for _, bucket := range results {

		if len(bucket) > 0 {

			var elapsedTime time.Duration

			if startTime == time.Unix(0, 0) {
				startTime = bucket[0].Timestamp
			}
			elapsedTime = bucket[0].Timestamp.Sub(startTime)

			row := Row{
				StartTime:      bucket[0].Timestamp,
				ElapsedTime:    elapsedTime,
				Threads:        0,
				TotalRequests:  0,
				TotalFailures:  0,
				TotalSuccess:   0,
				TotalTimeouts:  0,
				AvgRequestTime: 0,
			}

			totalRequestTime := 0 * time.Second
			maxThreads := 0

			for _, r := range bucket {

				row.TotalRequests++

				if r.Error != nil {
					if _, ok := r.Error.(errors.Timeout); ok {
						row.TotalTimeouts++
					}

					row.TotalFailures++
				} else {
					row.TotalSuccess++
					totalRequestTime += r.RequestTime
				}

				if r.Threads > maxThreads {
					maxThreads = r.Threads
					row.Threads = maxThreads
				}
			}

			if totalRequestTime != 0 && row.TotalSuccess != 0 {
				avgTime := int64(totalRequestTime) / int64(row.TotalSuccess)
				row.AvgRequestTime = time.Duration(avgTime)
			}

			rows = append(rows, row)
		}
	}

	return rows
}
func (t *TabularResults) Tabulate(results []ResultSet) []Row {

	var rows []Row
	startTime := time.Unix(0, 0)

	for _, bucket := range results {

		if len(bucket) > 0 {

			var elapsedTime time.Duration

			if startTime == time.Unix(0, 0) {
				startTime = bucket[0].Timestamp
			}
			elapsedTime = bucket[0].Timestamp.Sub(startTime)

			row := Row{
				StartTime:      bucket[0].Timestamp,
				ElapsedTime:    elapsedTime,
				Threads:        0,
				TotalRequests:  0,
				TotalFailures:  0,
				TotalSuccess:   0,
				TotalTimeouts:  0,
				AvgRequestTime: 0,
			}

			totalRequestTime := 0 * time.Second
			maxThreads := 0

			for _, r := range bucket {

				row.TotalRequests++

				if r.Error != nil {
					if _, ok := r.Error.(errors.Timeout); ok {
						row.TotalTimeouts++
					}

					row.TotalFailures++
				} else {
					row.TotalSuccess++
					totalRequestTime += r.RequestTime
				}

				if r.Threads > maxThreads {
					maxThreads = r.Threads
					row.Threads = maxThreads
				}
			}

			if totalRequestTime != 0 && row.TotalSuccess != 0 {
				avgTime := int64(totalRequestTime) / int64(row.TotalSuccess)
				row.AvgRequestTime = time.Duration(avgTime)
			}

			rows = append(rows, row)
		}
	}

	return rows
}
// Tabulate transforms the ResultsSets and returns a slice of Row