Getting-Started/BB10: bb_measure_cpu.patch
File bb_measure_cpu.patch, 4.3 KB (added by bennylp, 11 years ago) |
---|
-
pjsip/include/pjsua-lib/pjsua_internal.h
128 128 pjsip_status_code last_code; /**< Last status code seen. */ 129 129 pj_str_t last_text; /**< Last status text seen. */ 130 130 pj_time_val start_time;/**< First INVITE sent/received. */ 131 pj_uint32_t ms_utime; /**< Starting tms.tms_utime in msec */ 132 pj_uint32_t ms_stime; /**< Starting tms.tms_stime in msec */ 131 133 pj_time_val res_time; /**< First response sent/received. */ 132 134 pj_time_val conn_time; /**< Connected/confirmed time. */ 133 135 pj_time_val dis_time; /**< Disconnect time. */ -
pjsip/src/pjsua-lib/pjsua_dump.c
382 382 { 383 383 pjmedia_srtp_info *srtp_info = 384 384 (pjmedia_srtp_info*) tp_info.spc_info[j].buffer; 385 const char *policy_name = srtp_info->tx_policy.name.ptr; 385 386 387 if (!policy_name) 388 policy_name = ""; 389 386 390 len = pj_ansi_snprintf(p, end-p, 387 391 " %s SRTP status: %s Crypto-suite: %s", 388 392 indent, 389 393 (srtp_info->active?"Active":"Not active"), 390 srtp_info->tx_policy.name.ptr);394 policy_name); 391 395 if (len > 0 && len < end-p) { 392 396 p += len; 393 397 *p++ = '\n'; … … 912 916 buf[len] = '\0'; 913 917 } 914 918 919 void init_call_times(pj_uint32_t *ms_utime, pj_uint32_t *ms_stime); 915 920 916 921 /* 917 922 * Dump call and media statistics to string. … … 925 930 pjsua_call *call; 926 931 pjsip_dialog *dlg; 927 932 pj_time_val duration, res_delay, con_delay; 933 unsigned cpu_user_pct, cpu_system_pct; 928 934 char tmp[128]; 929 935 char *p, *end; 930 936 pj_status_t status; … … 970 976 res_delay.sec = res_delay.msec = 0; 971 977 } 972 978 979 if (call->ms_utime) { 980 pj_time_val now; 981 pj_uint32_t ms_duration, ms_utime, ms_stime; 982 983 pj_gettimeofday(&now); 984 PJ_TIME_VAL_SUB(now, call->start_time); 985 ms_duration = PJ_TIME_VAL_MSEC(now); 986 987 if (ms_duration != 0) { 988 init_call_times(&ms_utime, &ms_stime); 989 990 cpu_user_pct = (ms_utime - call->ms_utime) * 100 / ms_duration; 991 cpu_system_pct = (ms_stime - call->ms_stime) * 100 / ms_duration; 992 } else { 993 cpu_user_pct = cpu_system_pct = 0; 994 } 995 } 996 973 997 /* Print duration */ 974 998 len = pj_ansi_snprintf(p, end-p, 975 999 "%s Call time: %02dh:%02dm:%02ds, " 976 "1st res in %d ms, conn in %dms ",1000 "1st res in %d ms, conn in %dms, cpu (u|s|t)=%u|%u|%u%%", 977 1001 indent, 978 1002 (int)(duration.sec / 3600), 979 1003 (int)((duration.sec % 3600)/60), 980 1004 (int)(duration.sec % 60), 981 1005 (int)PJ_TIME_VAL_MSEC(res_delay), 982 (int)PJ_TIME_VAL_MSEC(con_delay)); 1006 (int)PJ_TIME_VAL_MSEC(con_delay), 1007 cpu_user_pct, cpu_system_pct, 1008 cpu_user_pct + cpu_system_pct); 983 1009 984 1010 if (len > 0 && len < end-p) { 985 1011 p += len; -
pjsip/src/pjsua-lib/pjsua_call.c
596 596 return PJ_SUCCESS; 597 597 } 598 598 599 #include <sys/times.h> 600 #include <time.h> 601 602 void init_call_times(pj_uint32_t *ms_utime, pj_uint32_t *ms_stime) 603 { 604 struct tms tms; 605 int ret; 606 607 ret = times(&tms); 608 609 if (1) { 610 *ms_utime = tms.tms_utime * 1000 / CLK_TCK; 611 *ms_stime = tms.tms_stime * 1000 / CLK_TCK; 612 } else { 613 *ms_utime = *ms_stime = 0; 614 } 615 } 616 599 617 /* 600 618 * Make outgoing call to the specified URI using the specified account. 601 619 */ … … 697 715 698 716 /* Mark call start time. */ 699 717 pj_gettimeofday(&call->start_time); 718 init_call_times(&call->ms_utime, &call->ms_stime); 700 719 701 720 /* Reset first response time */ 702 721 call->res_time.sec = 0; … … 1077 1096 1078 1097 /* Mark call start time. */ 1079 1098 pj_gettimeofday(&call->start_time); 1099 init_call_times(&call->ms_utime, &call->ms_stime); 1080 1100 1081 1101 /* Check INVITE request for Replaces header. If Replaces header is 1082 1102 * present, the function will make sure that we can handle the request.