server: add a few stopwatches

For measuring performance.
This commit is contained in:
Dirk-Jan C. Binnema 2023-01-19 00:38:26 +02:00
parent 87187d15d6
commit 201fe45edc
2 changed files with 10 additions and 3 deletions

View File

@ -687,6 +687,9 @@ Server::Private::find_handler(const Command& cmd)
if (threads)
qflags |= QueryFlags::Threading;
StopWatch sw{format("%s (indexing: %s)", __func__,
indexer().is_running() ? "yes" : "no")};
std::lock_guard l{store_.lock()};
auto qres{store_.run_query(q, sort_field->id, qflags, maxnum)};
if (!qres)
@ -778,6 +781,7 @@ Server::Private::index_handler(const Command& cmd)
// start a background track.
index_thread_ = std::thread([this, conf = std::move(conf)] {
StopWatch sw{"indexing"};
indexer().start(conf);
while (indexer().is_running()) {
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
@ -1024,6 +1028,9 @@ Server::Private::view_mark_as_read(Store::Id docid, Message&& msg, bool rename)
void
Server::Private::view_handler(const Command& cmd)
{
StopWatch sw{format("%s (indexing: %s)", __func__,
indexer().is_running() ? "yes" : "no")};
const auto mark_as_read{cmd.boolean_arg(":mark-as-read")};
/* for now, do _not_ rename, as it seems to confuse mbsync */
const auto rename{false};

View File

@ -231,11 +231,11 @@ struct StopWatch {
{
const auto us{static_cast<double>(to_us(Clock::now() - start_))};
if (us > 2000000)
g_debug("%s: finished after %0.1f s", name_.c_str(), us / 1000000);
g_debug("sw: %s: finished after %0.1f s", name_.c_str(), us / 1000000);
else if (us > 2000)
g_debug("%s: finished after %0.1f ms", name_.c_str(), us / 1000);
g_debug("sw: %s: finished after %0.1f ms", name_.c_str(), us / 1000);
else
g_debug("%s: finished after %g us", name_.c_str(), us);
g_debug("sw: %s: finished after %g us", name_.c_str(), us);
}
private: