forked from lix-project/lix
Convert NIX_COUNT_CALLS to JSON too
This commit is contained in:
parent
0a2545f95c
commit
91405986f4
|
@ -1728,7 +1728,6 @@ bool EvalState::eqValues(Value & v1, Value & v2)
|
||||||
void EvalState::printStats()
|
void EvalState::printStats()
|
||||||
{
|
{
|
||||||
bool showStats = getEnv("NIX_SHOW_STATS", "0") != "0";
|
bool showStats = getEnv("NIX_SHOW_STATS", "0") != "0";
|
||||||
Verbosity v = showStats ? lvlInfo : lvlDebug;
|
|
||||||
|
|
||||||
struct rusage buf;
|
struct rusage buf;
|
||||||
getrusage(RUSAGE_SELF, &buf);
|
getrusage(RUSAGE_SELF, &buf);
|
||||||
|
@ -1779,7 +1778,7 @@ void EvalState::printStats()
|
||||||
sets.attr("elements", nrAttrsInAttrsets);
|
sets.attr("elements", nrAttrsInAttrsets);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JSONObject sizes = topObj.object("sizes");
|
auto sizes = topObj.object("sizes");
|
||||||
sizes.attr("Env", sizeof(Env));
|
sizes.attr("Env", sizeof(Env));
|
||||||
sizes.attr("Value", sizeof(Value));
|
sizes.attr("Value", sizeof(Value));
|
||||||
sizes.attr("Bindings", sizeof(Bindings));
|
sizes.attr("Bindings", sizeof(Bindings));
|
||||||
|
@ -1793,40 +1792,47 @@ void EvalState::printStats()
|
||||||
topObj.attr("nrPrimOpCalls", nrPrimOpCalls);
|
topObj.attr("nrPrimOpCalls", nrPrimOpCalls);
|
||||||
topObj.attr("nrFunctionCalls", nrFunctionCalls);
|
topObj.attr("nrFunctionCalls", nrFunctionCalls);
|
||||||
#if HAVE_BOEHMGC
|
#if HAVE_BOEHMGC
|
||||||
JSONObject gc = topObj.object("gc");
|
{
|
||||||
gc.attr("heapSize", heapSize);
|
auto gc = topObj.object("gc");
|
||||||
gc.attr("totalBytes", totalBytes);
|
gc.attr("heapSize", heapSize);
|
||||||
|
gc.attr("totalBytes", totalBytes);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
if (countCalls) {
|
||||||
|
{
|
||||||
|
auto obj = topObj.object("primops");
|
||||||
if (countCalls) {
|
for (auto & i : primOpCalls)
|
||||||
v = lvlInfo;
|
obj.attr(i.first, i.second);
|
||||||
|
}
|
||||||
printMsg(v, format("calls to %1% primops:") % primOpCalls.size());
|
{
|
||||||
typedef std::multimap<size_t, Symbol> PrimOpCalls_;
|
auto list = topObj.list("functions");
|
||||||
PrimOpCalls_ primOpCalls_;
|
for (auto & i : functionCalls) {
|
||||||
for (auto & i : primOpCalls)
|
auto obj = list.object();
|
||||||
primOpCalls_.insert(std::pair<size_t, Symbol>(i.second, i.first));
|
if (i.first->name.set())
|
||||||
for (auto i = primOpCalls_.rbegin(); i != primOpCalls_.rend(); ++i)
|
obj.attr("name", (const string &) i.first->name);
|
||||||
printMsg(v, format("%1$10d %2%") % i->first % i->second);
|
else
|
||||||
|
obj.attr("name", nullptr);
|
||||||
printMsg(v, format("calls to %1% functions:") % functionCalls.size());
|
if (i.first->pos) {
|
||||||
typedef std::multimap<size_t, ExprLambda *> FunctionCalls_;
|
obj.attr("file", (const string &) i.first->pos.file);
|
||||||
FunctionCalls_ functionCalls_;
|
obj.attr("line", i.first->pos.line);
|
||||||
for (auto & i : functionCalls)
|
obj.attr("column", i.first->pos.column);
|
||||||
functionCalls_.insert(std::pair<size_t, ExprLambda *>(i.second, i.first));
|
}
|
||||||
for (auto i = functionCalls_.rbegin(); i != functionCalls_.rend(); ++i)
|
obj.attr("count", i.second);
|
||||||
printMsg(v, format("%1$10d %2%") % i->first % i->second->showNamePos());
|
}
|
||||||
|
}
|
||||||
printMsg(v, format("evaluations of %1% attributes:") % attrSelects.size());
|
{
|
||||||
typedef std::multimap<size_t, Pos> AttrSelects_;
|
auto list = topObj.list("attributes");
|
||||||
AttrSelects_ attrSelects_;
|
for (auto & i : attrSelects) {
|
||||||
for (auto & i : attrSelects)
|
auto obj = list.object();
|
||||||
attrSelects_.insert(std::pair<size_t, Pos>(i.second, i.first));
|
if (i.first) {
|
||||||
for (auto i = attrSelects_.rbegin(); i != attrSelects_.rend(); ++i)
|
obj.attr("file", (const string &) i.first.file);
|
||||||
printMsg(v, format("%1$10d %2%") % i->first % i->second);
|
obj.attr("line", i.first.line);
|
||||||
|
obj.attr("column", i.first.column);
|
||||||
|
}
|
||||||
|
obj.attr("count", i.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue