зеркало из https://github.com/mozilla/pjs.git
Sorting in category report
This commit is contained in:
Родитель
0625c66f3a
Коммит
3674b51e05
|
@ -47,6 +47,11 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Ugh, MSVC6's qsort is too slow...
|
||||||
|
*/
|
||||||
|
#include "nsQuickSort.h"
|
||||||
|
|
||||||
#if defined(HAVE_BOUTELL_GD)
|
#if defined(HAVE_BOUTELL_GD)
|
||||||
/*
|
/*
|
||||||
** See http://www.boutell.com/gd for the GD graphics library.
|
** See http://www.boutell.com/gd for the GD graphics library.
|
||||||
|
@ -590,9 +595,9 @@ PRBool printNodeProcessor(void* clientData, STCategoryNode* node)
|
||||||
{
|
{
|
||||||
STCategoryNode* root = (STCategoryNode*) clientData;
|
STCategoryNode* root = (STCategoryNode*) clientData;
|
||||||
if (node->nchildren)
|
if (node->nchildren)
|
||||||
fprintf(stderr, "%-20s [%d children]\n", node->categoryName, node->nchildren);
|
fprintf(stderr, "%-25s [%d children]\n", node->categoryName, node->nchildren);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "%-20s [ %7d allocations, %7d size, %4.1f%% ]\n", node->categoryName,
|
fprintf(stderr, "%-25s [ %7d allocations, %7d size, %4.1f%% ]\n", node->categoryName,
|
||||||
node->run ? node->run->mStats.mCompositeCount:0,
|
node->run ? node->run->mStats.mCompositeCount:0,
|
||||||
node->run ? node->run->mStats.mSize:0,
|
node->run ? node->run->mStats.mSize:0,
|
||||||
node->run ? ((double)node->run->mStats.mSize / root->run->mStats.mSize * 100):0
|
node->run ? ((double)node->run->mStats.mSize / root->run->mStats.mSize * 100):0
|
||||||
|
@ -602,6 +607,54 @@ PRBool printNodeProcessor(void* clientData, STCategoryNode* node)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** compareNode
|
||||||
|
**
|
||||||
|
** qsort callback.
|
||||||
|
** Compare the nodes as specified by the options.
|
||||||
|
*/
|
||||||
|
int compareNode(const void* aNode1, const void* aNode2, void* aContext)
|
||||||
|
{
|
||||||
|
int retval = 0;
|
||||||
|
STCategoryNode* node1, * node2;
|
||||||
|
PRUint32 a, b;
|
||||||
|
|
||||||
|
if (!aNode1 || !aNode2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
node1 = *((STCategoryNode **) aNode1);
|
||||||
|
node2 = *((STCategoryNode **) aNode2);
|
||||||
|
|
||||||
|
if (node1 && node2)
|
||||||
|
{
|
||||||
|
if (globals.mOptions.mOrderBy == ST_COUNT)
|
||||||
|
{
|
||||||
|
a = (node1->run) ? node1->run->mStats.mCompositeCount : 0;
|
||||||
|
b = (node2->run) ? node2->run->mStats.mCompositeCount : 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Default is by size */
|
||||||
|
a = (node1->run) ? node1->run->mStats.mSize : 0;
|
||||||
|
b = (node2->run) ? node2->run->mStats.mSize : 0;
|
||||||
|
}
|
||||||
|
if (a < b)
|
||||||
|
retval = __LINE__;
|
||||||
|
else
|
||||||
|
retval = - __LINE__;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRBool sortNodeProcessor(void* clientData, STCategoryNode* node)
|
||||||
|
{
|
||||||
|
if (node->nchildren)
|
||||||
|
NS_QuickSort(node->children, node->nchildren, sizeof(STCategoryNode *), compareNode, NULL);
|
||||||
|
|
||||||
|
return PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** walkTree
|
** walkTree
|
||||||
**
|
**
|
||||||
|
@ -748,7 +801,6 @@ int categorizeRun(const STRun* aRun, STGlobals* g)
|
||||||
g->mCategoryRoot.categoryName = ST_ROOT_CATEGORY_NAME;
|
g->mCategoryRoot.categoryName = ST_ROOT_CATEGORY_NAME;
|
||||||
|
|
||||||
#if defined(DEBUG_dp)
|
#if defined(DEBUG_dp)
|
||||||
walkTree(&g->mCategoryRoot, printNodeProcessor, &g->mCategoryRoot, 0);
|
|
||||||
fprintf(stderr, "DEBUG: categorizing ends: %dms [%d rules, %d allocations]\n",
|
fprintf(stderr, "DEBUG: categorizing ends: %dms [%d rules, %d allocations]\n",
|
||||||
PR_IntervalToMilliseconds(PR_IntervalNow() - start), g->mNRules, aRun->mAllocationCount);
|
PR_IntervalToMilliseconds(PR_IntervalNow() - start), g->mNRules, aRun->mAllocationCount);
|
||||||
fprintf(stderr, "DEBUG: match : %dms [%d calls, %d rule-compares]\n",
|
fprintf(stderr, "DEBUG: match : %dms [%d calls, %d rule-compares]\n",
|
||||||
|
@ -756,6 +808,15 @@ int categorizeRun(const STRun* aRun, STGlobals* g)
|
||||||
_gMatchCount, _gMatchRules);
|
_gMatchCount, _gMatchRules);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** sort the tree based on our sort criterion
|
||||||
|
*/
|
||||||
|
walkTree(&g->mCategoryRoot, sortNodeProcessor, NULL, 0);
|
||||||
|
|
||||||
|
#if defined(DEBUG_dp)
|
||||||
|
walkTree(&g->mCategoryRoot, printNodeProcessor, &g->mCategoryRoot, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче