func DiffProfiles(before []*cover.Profile, after []*cover.Profile) ([]*cover.Profile, error) {
	var diff []*cover.Profile
	if len(before) != len(after) {
		return nil, fmt.Errorf("before and after have different numbers of profiles (%d vs. %d)", len(before), len(after))
	}
	for i, beforeProfile := range before {
		afterProfile := after[i]
		if err := ensureProfilesMatch(beforeProfile, afterProfile); err != nil {
			return nil, fmt.Errorf("error on profile #%d: %v", i, err)
		}
		diffProfile := cover.Profile{FileName: beforeProfile.FileName, Mode: beforeProfile.Mode}
		for j, beforeBlock := range beforeProfile.Blocks {
			afterBlock := afterProfile.Blocks[j]
			diffBlock := cover.ProfileBlock{
				StartLine: beforeBlock.StartLine,
				StartCol:  beforeBlock.StartCol,
				EndLine:   beforeBlock.EndLine,
				EndCol:    beforeBlock.EndCol,
				NumStmt:   beforeBlock.NumStmt,
				Count:     afterBlock.Count - beforeBlock.Count,
			}
			diffProfile.Blocks = append(diffProfile.Blocks, diffBlock)
		}
		diff = append(diff, &diffProfile)
	}
	return diff, nil
}
func DiffProfiles(before []*cover.Profile, after []*cover.Profile) ([]*cover.Profile, error) {
	var diff []*cover.Profile
	if len(before) != len(after) {
		return nil, fmt.Errorf("before and after have different numbers of profiles (%d vs. %d)", len(before), len(after))
	}
	for i, beforeProfile := range before {
		afterProfile := after[i]
		if err := ensureProfilesMatch(beforeProfile, afterProfile); err != nil {
			return nil, fmt.Errorf("error on profile #%d: %v", i, err)
		}
		diffProfile := cover.Profile{FileName: beforeProfile.FileName, Mode: beforeProfile.Mode}
		for j, beforeBlock := range beforeProfile.Blocks {
			afterBlock := afterProfile.Blocks[j]
			diffBlock := cover.ProfileBlock{
				StartLine: beforeBlock.StartLine,
				StartCol:  beforeBlock.StartCol,
				EndLine:   beforeBlock.EndLine,
				EndCol:    beforeBlock.EndCol,
				NumStmt:   beforeBlock.NumStmt,
				Count:     afterBlock.Count - beforeBlock.Count,
			}
			diffProfile.Blocks = append(diffProfile.Blocks, diffBlock)
		}
		diff = append(diff, &diffProfile)
	}
	return diff, nil
}
// DiffProfiles returns the difference between two sets of coverage profiles.
// The profiles are expected to be from a single execution of the same binary
// (or multiple binaries, if using a merged coverage profile)