float btp_thread_quality(struct btp_thread *thread) { int ok_count = 0, all_count = 0; btp_thread_quality_counts(thread, &ok_count, &all_count); if (0 == all_count) return 1; return ok_count/(float)all_count; }
PyObject *p_btp_thread_quality_counts(PyObject *self, PyObject *args) { ThreadObject *this = (ThreadObject *)self; if (thread_prepare_linked_list(this) < 0) return NULL; int ok = 0, all = 0; btp_thread_quality_counts(this->thread, &ok, &all); return Py_BuildValue("(ii)", ok, all); }
struct btp_distances * btp_threads_compare(struct btp_thread **threads, int m, int n, btp_dist_thread_type dist_func) { struct btp_distances *distances; struct btp_thread *thread1, *thread2; int i, j, ok, all; distances = btp_distances_new(m, n); for (i = 0; i < m; i++) for (j = i + 1; j < n; j++) { ok = all = 0; btp_thread_quality_counts(threads[i], &ok, &all); btp_thread_quality_counts(threads[j], &ok, &all); if (ok == all) { thread1 = threads[i]; thread2 = threads[j]; } else { /* There are some unknown function names, try to pair them, but * the threads need to be copied first. */ thread1 = btp_thread_dup(threads[i], false); thread2 = btp_thread_dup(threads[j], false); btp_normalize_paired_unknown_function_names(thread1, thread2); } distances->distances[get_distance_position(distances, i, j)] = dist_func(thread1, thread2); if (ok != all) { btp_thread_free(thread1); btp_thread_free(thread2); } } return distances; }
float btp_backtrace_quality_simple(struct btp_backtrace *backtrace) { int ok_count = 0, all_count = 0; struct btp_thread *thread = backtrace->threads; while (thread) { btp_thread_quality_counts(thread, &ok_count, &all_count); thread = thread->next; } if (all_count == 0) return 0; return ok_count / (float)all_count; }