prg_profiles_merge_bt()
摘要
通过合并两个现有 profile 创建新的 profile。
语法
prg_profiles_merge_bt (merge_op, profile_a, profile_b, options)
| 参数 | 类型 | 说明 |
|---|---|---|
merge_op |
PrgT_Profile_Merge_Op |
要执行的合并操作(见详情中的 merge_op 参数)。 |
profile_a |
PrgT_Profile_Handle |
第一个源 profile 的句柄。 |
profile_b |
PrgT_Profile_Handle |
第二个源 profile 的句柄。 |
options |
int |
数据选项(见详情中的 options 参数)。 |
返回类型
PrgT_Profile_Handle
新的合并后 profile 的句柄。
头文件
prg_profile_funcs.h
详情
此函数接收两个 profile,并基于两个源 profile 的 x-y 数据创建一个新的、未附加的 profile。(profile 中的字符串数据不会被合并。)源 profile 保持不变。使用前必须将新 profile 附加到 profile 库。
源 profile 必须具有相同的 x 和 y 单位。通过比较两个 profile 的起始时间来确保数据正确对齐。结果 profile 将采用两个起始时间中较早的一个。
只有重叠且均已定义的 y 值才会被合并;被合并 profile 中未定义的值将被忽略。
merge_op 参数
新 profile 为源 profile 中每个唯一的 x 值包含一个条目。新 profile 中的 y 值根据 merge_op 的值确定。
PrgC_Profile_Merge_Add——每个新的 y 值是源 profile 中对应 y 值之和。PrgC_Profile_Merge_Min——每个新的 y 值是源 profile 中对应 y 值中的较小者。PrgC_Profile_Merge_Max——每个新的 y 值是源 profile 中对应 y 值中的较大者。PrgC_Profile_Merge_Avg——每个新的 y 值是源 profile 中对应 y 值的平均值。
options 参数
options 参数是以下选项的按位或(OR)组合:
-
PRGC_PROFILE_MERGE_OPT_NONE -
PRGC_PROFILE_MERGE_OPT_USE_START_TIME——合并时考虑 profile 的起始时间。两个 profile 必须都指定起始时间,或都不指定。 -
PRGC_PROFILE_MERGE_OPT_START_TIME_FORCED——与PRGC_PROFILE_MERGE_OPT_USE_START_TIME配合使用,即使只有一个 profile 指定了起始时间,也考虑 profile 的起始时间。 -
PRGC_PROFILE_MERGE_OPT_NO_MERGE_LAST——不要将某个 profile 的最后一个数据点与另一个 profile 中更晚的数据点合并。默认情况下,假定 profile 最后一个条目的 y 值会无限延伸。当两个不相关的 profile 合并时,这可能导致意外结果,因为一个 profile 中的最后一个条目将与另一个 profile 中所有后续条目合并。指定此选项后,profile 的最后一个条目只延伸到另一个 profile 中第一个后续条目为止。
图 4 展示了在默认模式下以及使用
PRGC_PROFILE_MERGE_OPT_NO_MERGE_LAST选项时合并两个 profile 的结果(merge_op设为PrgC_Profile_Merge_Add)。
图 4:profile 合并示例
Merged Profile Merged Profile
Profile A Profile B (Default) (With option)
--------- --------- -------------- --------------
0 100 0 100 0 100
100 400 100 400 100 400
150 200 150 600 150 600
200 600 200 500 200 1100 200 1100
300 300 300 900 300 300
400 100 400 700 400 100
要获得已弃用函数 prg_profiles_merge() 的功能,请在调用此函数时将 options 设为 PRGC_PROFILE_MERGE_OPT_NONE。
符号常量
表 3:Profile 包/数据子包符号常量
| 说明 | 类型 | 符号常量 |
|---|---|---|
| 无效 profile 句柄 | PrgT_Profile_Handle |
PRGC_NIL_PROFILE_HANDLE |
| 数据选项 | int |
PRGC_PROFILE_DATA_OPT_NONEPRGC_PROFILE_DATA_OPT_TIME_ABSPRGC_PROFILE_DATA_OPT_INCLUDE_INITIALPRGC_PROFILE_DATA_OPT_INCLUDE_UNDEFINED |
| 合并操作 | PrgT_Profile_Merge_Op |
PrgC_Profile_Merge_AddPrgC_Profile_Merge_MinPrgC_Profile_Merge_MaxPrgC_Profile_Merge_Avg |
| 合并选项 | int |
PRGC_PROFILE_MERGE_OPT_NONEPRGC_PROFILE_MERGE_OPT_USE_START_TIMEPRGC_PROFILE_MERGE_OPT_START_TIME_FORCEDPRGC_PROFILE_MERGE_OPT_NO_MERGE_LAST |
| 缩放操作 | PrgT_Profile_Scale_Op |
PrgC_Profile_Scale_Op_AddPrgC_Profile_Scale_Op_Multiply |