コード例 #1
0
ファイル: core_profiler.cpp プロジェクト: Dauch/b20141027
int lprofP_output(lprofP_STATE* S){
	if (S->stack_level == 0) {
		return 0;
	}

	S->stack_level--;

	info = &lprofS_pop(&(S->stack_top));

	char* name = info->function_name;
	if (strlen(name) > MAX_FUNCTION_NAME_LENGTH) {
		name = (char*)malloc(MAX_FUNCTION_NAME_LENGTH + 10);
		name[0] = '\"';
		strncpy(name + 1, info->function_name, MAX_FUNCTION_NAME_LENGTH);
		name[MAX_FUNCTION_NAME_LENGTH] = '"';
		name[MAX_FUNCTION_NAME_LENGTH + 1] = '\0';
	}
	formats(name);

	output("%d\t%s\t%s\t%d\t%d\t%f\t%f\n", info->stack_level, info->file_defined, name,
		info->line_defined, info->current_line,
		info->local_time, info->total_time);

	return 1;
}
コード例 #2
0
/* because the funcinfo will be overwritten               */
lprofS_STACK_RECORD *lprofM_leave_function(lprofP_STATE* S, int isto_resume) {

  ASSERT(S->stack_top, "leave_function: stack_top null");

  leave_ret = lprofS_pop(&(S->stack_top));
  compute_local_time(&leave_ret);
  compute_total_time(&leave_ret);
  /* resume the timer for the parent function ? */
  if (isto_resume)
    lprofM_resume_local_time(S);
  return &leave_ret;
}