irc: add timing measurements; formatting
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Id4402547e18b6569464850c3753383396a6a6964
This commit is contained in:
parent
b6fd2326a6
commit
84cf5fdf68
2 changed files with 16 additions and 3 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include "irc/serializer.h"
|
||||
#include "irc/types.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
namespace nix_ir_plugin {
|
||||
|
|
@ -29,6 +30,8 @@ static void prim_loadIR(EvalState& state, const PosIdx pos, Value** args, Value&
|
|||
|
||||
std::string pathStr(path);
|
||||
|
||||
auto t_start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
Deserializer deserializer;
|
||||
IRModule module;
|
||||
|
||||
|
|
@ -38,6 +41,8 @@ static void prim_loadIR(EvalState& state, const PosIdx pos, Value** args, Value&
|
|||
state.error<EvalError>("failed to deserialize IR bundle: %s", e.what()).atPos(pos).debugThrow();
|
||||
}
|
||||
|
||||
auto t_deser = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if (!module.entry) {
|
||||
state.error<EvalError>("IR bundle has no entry point").atPos(pos).debugThrow();
|
||||
}
|
||||
|
|
@ -48,6 +53,14 @@ static void prim_loadIR(EvalState& state, const PosIdx pos, Value** args, Value&
|
|||
} catch (const std::exception& e) {
|
||||
state.error<EvalError>("failed to evaluate IR: %s", e.what()).atPos(pos).debugThrow();
|
||||
}
|
||||
|
||||
auto t_eval = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto deser_us = std::chrono::duration_cast<std::chrono::microseconds>(t_deser - t_start).count();
|
||||
auto eval_us = std::chrono::duration_cast<std::chrono::microseconds>(t_eval - t_deser).count();
|
||||
|
||||
std::cerr << "nixIR timing: deser=" << deser_us << "us eval=" << eval_us
|
||||
<< "us total=" << (deser_us + eval_us) << "us" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -139,7 +152,7 @@ static RegisterPrimOp rp_info({
|
|||
|
||||
} // namespace nix_ir_plugin
|
||||
|
||||
// Plugin initialization message
|
||||
// Plugin initialization
|
||||
__attribute__((constructor)) static void init_plugin() {
|
||||
std::cerr << "nix-ir-plugin loaded" << std::endl;
|
||||
// Plugin loads silently...
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue