Add some support for CPU profiling

This commit is contained in:
2021-12-17 16:21:56 -05:00
parent cfa6c28d34
commit 227a754b21
4 changed files with 33 additions and 1 deletions

View File

@@ -150,6 +150,17 @@ public:
rescan_lua_source();
}
void do_work_command(const util::StringVec &words) {
int reps = 10000;
int64_t t1 = util::profiling_clock();
for (int i = 0; i < reps; i++) {
world_to_synchronous();
world_to_asynchronous();
}
int64_t t2 = util::profiling_clock();
stdostream() << "Snapshot/rollback took " << ((t2-t1)/reps) << " nanosec." << std::endl;
}
void do_quit_command(const util::StringVec &words) {
abandon_server();
stop_driver();
@@ -165,6 +176,7 @@ public:
else if (words[0] == "choose") do_choose_command(words);
else if (words[0] == "tick") do_tick_command(words);
else if (words[0] == "cpl") do_cpl_command(words);
else if (words[0] == "work") do_work_command(words);
else if (words[0] == "quit") do_quit_command(words);
else {
stdostream() << "Unsupported command: " << words[0] << std::endl;