mirror of
https://github.com/typesense/typesense.git
synced 2025-05-18 12:42:50 +08:00
Util for logging exec time.
This commit is contained in:
parent
9d5a120dab
commit
d8eee0d04a
17
include/exectime.h
Normal file
17
include/exectime.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
||||
class ExecTime {
|
||||
static auto begin = std::chrono::high_resolution_clock::now();
|
||||
|
||||
static void start() {
|
||||
begin = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
static void log(std::string operation) {
|
||||
long long int timeMicros = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::high_resolution_clock::now() - begin).count();
|
||||
std::cout << "Time taken for " << operation << ": " << timeMicros << "us" << std::endl;
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user