Add some TODOs
This commit is contained in:
parent
3095cbd956
commit
9b42d4f4f8
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -1861,6 +1861,7 @@ Produce::ProduceCursor::ProduceCursor(const Produce &self, utils::MemoryResource
|
|||||||
|
|
||||||
bool Produce::ProduceCursor::Pull(Frame &frame, ExecutionContext &context) {
|
bool Produce::ProduceCursor::Pull(Frame &frame, ExecutionContext &context) {
|
||||||
SCOPED_PROFILE_OP("Produce");
|
SCOPED_PROFILE_OP("Produce");
|
||||||
|
MG_RAII_TIMER(timer, "PRODUCE_PULL v2");
|
||||||
|
|
||||||
if (input_cursor_->Pull(frame, context)) {
|
if (input_cursor_->Pull(frame, context)) {
|
||||||
// Produce should always yield the latest results.
|
// Produce should always yield the latest results.
|
||||||
|
@ -1108,6 +1108,7 @@ Produce::ProduceCursor::ProduceCursor(const Produce &self, utils::MemoryResource
|
|||||||
|
|
||||||
bool Produce::ProduceCursor::Pull(Frame &frame, ExecutionContext &context) {
|
bool Produce::ProduceCursor::Pull(Frame &frame, ExecutionContext &context) {
|
||||||
SCOPED_PROFILE_OP("Produce");
|
SCOPED_PROFILE_OP("Produce");
|
||||||
|
MG_RAII_TIMER(timer, "PRODUCE_PULL v3");
|
||||||
|
|
||||||
if (input_cursor_->Pull(frame, context)) {
|
if (input_cursor_->Pull(frame, context)) {
|
||||||
// Produce should always yield the latest results.
|
// Produce should always yield the latest results.
|
||||||
|
@ -15,10 +15,14 @@
|
|||||||
|
|
||||||
namespace memgraph::utils {
|
namespace memgraph::utils {
|
||||||
|
|
||||||
|
// TODO(gitbuda): Figure out the relation with tsc.hpp
|
||||||
|
// TODO(gitbuda): Consider adding system_clock as an option
|
||||||
|
|
||||||
// This class is threadsafe.
|
// This class is threadsafe.
|
||||||
template <typename TTime = std::chrono::duration<double>>
|
template <typename TTime = std::chrono::duration<double>>
|
||||||
class Timer {
|
class Timer {
|
||||||
public:
|
public:
|
||||||
|
// TODO(gitbuda): Timer(TFun&& destroy_callback...
|
||||||
Timer(std::function<void(decltype(std::declval<TTime>().count()) elapsed)> destroy_callback = nullptr)
|
Timer(std::function<void(decltype(std::declval<TTime>().count()) elapsed)> destroy_callback = nullptr)
|
||||||
: start_time_(std::chrono::steady_clock::now()), destroy_callback_(destroy_callback) {}
|
: start_time_(std::chrono::steady_clock::now()), destroy_callback_(destroy_callback) {}
|
||||||
|
|
||||||
@ -35,16 +39,18 @@ class Timer {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::chrono::steady_clock::time_point start_time_;
|
std::chrono::steady_clock::time_point start_time_;
|
||||||
|
// TODO(gitbuda): std::function is an overhead, replace with TFun
|
||||||
std::function<void(decltype(std::declval<TTime>().count()))> destroy_callback_ = nullptr;
|
std::function<void(decltype(std::declval<TTime>().count()))> destroy_callback_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define __MG_RAII_TIMER(name, message) \
|
// The intention with the macro is to have an easy way to probe how long a
|
||||||
|
// certain code block takes. It should be a short living piece of code. For
|
||||||
|
// something that has to stay longer in the code, please use the Timer
|
||||||
|
// directly.
|
||||||
|
// TODO(gitbuda): Maybe a desired property would be to at any given time, turn
|
||||||
|
// some of them ON/OFF (not all).
|
||||||
|
//
|
||||||
|
#define MG_RAII_TIMER(name, message) \
|
||||||
memgraph::utils::Timer<> name([](auto elapsed) { spdlog::critical("{} {}s", message, elapsed); })
|
memgraph::utils::Timer<> name([](auto elapsed) { spdlog::critical("{} {}s", message, elapsed); })
|
||||||
// TODO(gitbuda): Swap MG_TIMER defines
|
|
||||||
#ifdef MG_TIMER
|
|
||||||
#define MG_RAII_TIMER(name, message)
|
|
||||||
#else
|
|
||||||
#define MG_RAII_TIMER(name, message) __MG_RAII_TIMER(name, message)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace memgraph::utils
|
} // namespace memgraph::utils
|
||||||
|
Loading…
Reference in New Issue
Block a user