Example #1
0
// helper function to format aggregated breakdown results
func formatBreakdown(bdown Record, breakdown string) string {
	report := ""
	if breakdown == "" {
		return report
	}
	keys := utils.MapKeys(bdown)
	lsize := 0
	if breakdown == "tier" {
		sort.Sort(utils.StringList(keys))
		for _, k := range keys {
			if len(k) > lsize {
				lsize = len(k)
			}
		}
	}
	for _, k := range keys {
		v := bdown[k]
		size := v.(float64)
		pad := ""
		if breakdown == "tier" {
			if len(k) < lsize {
				pad = strings.Repeat(" ", (lsize - len(k)))
			}
		}
		report += fmt.Sprintf("   %s%s\t%f (%s)\n", k, pad, size, utils.SizeFormat(size))
	}
	return report
}
Example #2
0
// helper function to format aggregated results
func formatResults(metric string, bins []int, records []Record, breakdown string) {
	for _, rec := range records {
		for site, vals := range rec {
			rec := vals.(Record)
			results := rec["results"].(BinRecord)
			bresults := rec["breakdown"].(BinRecord)
			//             results := vals.(Record)
			report := fmt.Sprintf("%s:\n", site)
			ikeys := utils.MapIntKeys(results)
			sort.Ints(ikeys)
			pad := ""
			for _, bin := range ikeys {
				size := results[bin].(float64)
				bdown := bresults[bin].(Record)
				if bin == bins[len(bins)-1] {
					pad = "+"
				}
				report += fmt.Sprintf("%s %d%s size %f (%s)\n", metric, bin, pad, size, utils.SizeFormat(size))
				report += formatBreakdown(bdown, breakdown)
			}
			fmt.Println(report)
		}
	}
}