diff --git a/userspace/libsinsp/CMakeLists.txt b/userspace/libsinsp/CMakeLists.txt index 1bee6ec812..49ce0496bb 100644 --- a/userspace/libsinsp/CMakeLists.txt +++ b/userspace/libsinsp/CMakeLists.txt @@ -127,7 +127,6 @@ set(SINSP_SOURCES sinsp.cpp stats.cpp token_bucket.cpp - stopwatch.cpp utils.cpp value_parser.cpp user.cpp diff --git a/userspace/libsinsp/stopwatch.cpp b/userspace/libsinsp/stopwatch.cpp deleted file mode 100644 index ca8a859c08..0000000000 --- a/userspace/libsinsp/stopwatch.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -/* -Copyright (C) 2023 The Falco Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -*/ -// -// stopwatch.cpp -// -// stopwatch utility -// - -#include "stopwatch.h" - -sinsp_stopwatch::sinsp_stopwatch() -{ - start(); -} diff --git a/userspace/libsinsp/stopwatch.h b/userspace/libsinsp/stopwatch.h deleted file mode 100644 index ad69d17b2c..0000000000 --- a/userspace/libsinsp/stopwatch.h +++ /dev/null @@ -1,69 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -/* -Copyright (C) 2023 The Falco Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -*/ -// -// stopwatch.h -// -// stopwatch utility -// - -#pragma once - -#include - -class sinsp_stopwatch -{ -public: - sinsp_stopwatch(); - - void stop(); - void start(); - void reset(); - - template - typename T::rep elapsed() const - { - return std::chrono::duration_cast(m_stop - m_start).count(); - } - -private: - void record(std::chrono::high_resolution_clock::time_point& tp); - - std::chrono::high_resolution_clock::time_point m_start; - std::chrono::high_resolution_clock::time_point m_stop; -}; - -inline void sinsp_stopwatch::sinsp_stopwatch::reset() -{ - m_start = std::chrono::high_resolution_clock::time_point::min(); - m_stop = m_start; -} - -inline void sinsp_stopwatch::sinsp_stopwatch::start() -{ - record(m_start); -} - -inline void sinsp_stopwatch::sinsp_stopwatch::stop() -{ - record(m_stop); -} - -inline void sinsp_stopwatch::record(std::chrono::high_resolution_clock::time_point& tp) -{ - tp = std::chrono::high_resolution_clock::now(); -}