mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
qsp: add sort_by option to qsp_report
Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
fe9959a275
commit
0a22777c71
2 changed files with 34 additions and 7 deletions
|
@ -13,7 +13,13 @@
|
||||||
|
|
||||||
#include "qemu/fprintf-fn.h"
|
#include "qemu/fprintf-fn.h"
|
||||||
|
|
||||||
void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max);
|
enum QSPSortBy {
|
||||||
|
QSP_SORT_BY_TOTAL_WAIT_TIME,
|
||||||
|
QSP_SORT_BY_AVG_WAIT_TIME,
|
||||||
|
};
|
||||||
|
|
||||||
|
void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max,
|
||||||
|
enum QSPSortBy sort_by);
|
||||||
|
|
||||||
bool qsp_is_enabled(void);
|
bool qsp_is_enabled(void);
|
||||||
void qsp_enable(void);
|
void qsp_enable(void);
|
||||||
|
|
33
util/qsp.c
33
util/qsp.c
|
@ -429,14 +429,34 @@ static gint qsp_tree_cmp(gconstpointer ap, gconstpointer bp, gpointer up)
|
||||||
{
|
{
|
||||||
const QSPEntry *a = ap;
|
const QSPEntry *a = ap;
|
||||||
const QSPEntry *b = bp;
|
const QSPEntry *b = bp;
|
||||||
|
enum QSPSortBy sort_by = *(enum QSPSortBy *)up;
|
||||||
const QSPCallSite *ca;
|
const QSPCallSite *ca;
|
||||||
const QSPCallSite *cb;
|
const QSPCallSite *cb;
|
||||||
|
|
||||||
if (a->ns > b->ns) {
|
switch (sort_by) {
|
||||||
return -1;
|
case QSP_SORT_BY_TOTAL_WAIT_TIME:
|
||||||
} else if (a->ns < b->ns) {
|
if (a->ns > b->ns) {
|
||||||
return 1;
|
return -1;
|
||||||
|
} else if (a->ns < b->ns) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QSP_SORT_BY_AVG_WAIT_TIME:
|
||||||
|
{
|
||||||
|
double avg_a = a->n_acqs ? a->ns / a->n_acqs : 0;
|
||||||
|
double avg_b = b->n_acqs ? b->ns / b->n_acqs : 0;
|
||||||
|
|
||||||
|
if (avg_a > avg_b) {
|
||||||
|
return -1;
|
||||||
|
} else if (avg_a < avg_b) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
|
|
||||||
ca = a->callsite;
|
ca = a->callsite;
|
||||||
cb = b->callsite;
|
cb = b->callsite;
|
||||||
/* Break the tie with the object's address */
|
/* Break the tie with the object's address */
|
||||||
|
@ -613,9 +633,10 @@ static void report_destroy(QSPReport *rep)
|
||||||
g_free(rep->entries);
|
g_free(rep->entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max)
|
void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max,
|
||||||
|
enum QSPSortBy sort_by)
|
||||||
{
|
{
|
||||||
GTree *tree = g_tree_new_full(qsp_tree_cmp, NULL, g_free, NULL);
|
GTree *tree = g_tree_new_full(qsp_tree_cmp, &sort_by, g_free, NULL);
|
||||||
QSPReport rep;
|
QSPReport rep;
|
||||||
|
|
||||||
qsp_init();
|
qsp_init();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue