about summary refs log blame commit diff
path: root/src/libexpr/function-trace.hh
blob: 8b0ec848d5a8675eb5778c6c16dab7d4215b0dc8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                                                     
                                                                                




                                                                                     
                                                                               


     
#pragma once

#include "eval.hh"
#include <sys/time.h>

namespace nix {

struct FunctionCallTrace
{
    const Pos & pos;

    FunctionCallTrace(const Pos & pos) : pos(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%", pos, ns.count());
    }

    ~FunctionCallTrace() {
        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%", pos, ns.count());
    }
};
}