mirror of
https://github.com/NixOS/nix
synced 2025-06-25 02:21:16 +02:00
Sometimes the profiler might want to do evaluation (e.g. for getting derivation names). This is not ideal, but is really necessary to make the profiler stack traces useful for end users.
22 lines
863 B
C++
22 lines
863 B
C++
#include "nix/expr/function-trace.hh"
|
|
#include "nix/util/logging.hh"
|
|
|
|
namespace nix {
|
|
|
|
void FunctionCallTrace::preFunctionCallHook(
|
|
EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
|
{
|
|
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
|
|
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
|
|
printMsg(lvlInfo, "function-trace entered %1% at %2%", state.positions[pos], ns.count());
|
|
}
|
|
|
|
void FunctionCallTrace::postFunctionCallHook(
|
|
EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
|
{
|
|
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
|
|
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
|
|
printMsg(lvlInfo, "function-trace exited %1% at %2%", state.positions[pos], ns.count());
|
|
}
|
|
|
|
}
|