Exemple #1
0
// helper function to yield CSV format
func formatCSV(bins []int, records []Record) {
	for _, rec := range records {
		for site, vals := range rec {
			out := site
			rec := vals.(Record)
			results := rec["results"].(BinRecord)
			ikeys := utils.MapIntKeys(results)
			sort.Ints(ikeys)
			for _, bin := range ikeys {
				size := results[bin].(float64)
				out += fmt.Sprintf(",%f", size)
			}
			fmt.Println(out)
		}
	}
}
Exemple #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)
		}
	}
}