mirror of
https://github.com/typesense/typesense.git
synced 2025-05-21 06:02:26 +08:00
17 lines
544 B
C++
17 lines
544 B
C++
#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;
|
|
}
|
|
}; |