├── .clang-format ├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── WORKSPACE ├── apache.lic ├── appveyor.bat ├── appveyor.yml ├── easy_profiler_converter ├── CMakeLists.txt ├── converter.cpp ├── converter.h ├── include │ └── json.hpp ├── main.cpp ├── reader.cpp └── reader.h ├── easy_profiler_core ├── BUILD ├── CMakeLists.txt ├── LICENSE.APACHE ├── LICENSE.MIT ├── alignment_helpers.h ├── base_block_descriptor.cpp ├── block.cpp ├── block_descriptor.cpp ├── block_descriptor.h ├── chunk_allocator.h ├── cmake │ ├── config.cmake.in │ ├── qnx-aarch64.cmake │ ├── qnx-armv7.cmake │ ├── qnx-x86_64.cmake │ └── qnx.cmake ├── current_thread.h ├── current_time.h ├── easy_socket.cpp ├── event_trace_status.h ├── event_trace_win.cpp ├── event_trace_win.h ├── hashed_cstr.h ├── include │ └── easy │ │ ├── arbitrary_value.h │ │ ├── details │ │ ├── arbitrary_value_aux.h │ │ ├── arbitrary_value_public_types.h │ │ ├── easy_compiler_support.h │ │ ├── profiler_aux.h │ │ ├── profiler_colors.h │ │ ├── profiler_in_use.h │ │ └── profiler_public_types.h │ │ ├── easy_net.h │ │ ├── easy_protocol.h │ │ ├── easy_socket.h │ │ ├── profiler.h │ │ ├── reader.h │ │ ├── serialized_block.h │ │ ├── utility.h │ │ └── writer.h ├── nonscoped_block.cpp ├── nonscoped_block.h ├── profile_manager.cpp ├── profile_manager.h ├── profiler.cpp ├── reader.cpp ├── resources.rc ├── serialized_block.cpp ├── spin_lock.h ├── stack_buffer.h ├── thread_storage.cpp ├── thread_storage.h └── writer.cpp ├── mit.lic ├── profiler_gui ├── CMakeLists.txt ├── arbitrary_value_inspector.cpp ├── arbitrary_value_inspector.h ├── arbitrary_value_tooltip.cpp ├── arbitrary_value_tooltip.h ├── blocks_graphics_view.cpp ├── blocks_graphics_view.h ├── blocks_tree_widget.cpp ├── blocks_tree_widget.h ├── bookmarks_editor.cpp ├── bookmarks_editor.h ├── common_functions.cpp ├── common_functions.h ├── common_types.h ├── complexity_calculator.h ├── descriptors_tree_widget.cpp ├── descriptors_tree_widget.h ├── dialog.cpp ├── dialog.h ├── file_reader.cpp ├── file_reader.h ├── fps_widget.cpp ├── fps_widget.h ├── globals.cpp ├── globals.h ├── globals_qobjects.cpp ├── globals_qobjects.h ├── graphics_block_item.cpp ├── graphics_block_item.h ├── graphics_image_item.cpp ├── graphics_image_item.h ├── graphics_ruler_item.cpp ├── graphics_ruler_item.h ├── graphics_scrollbar.cpp ├── graphics_scrollbar.h ├── graphics_slider_area.cpp ├── graphics_slider_area.h ├── images │ ├── attribution.txt │ ├── default │ │ ├── arrow-down-disabled.svg │ │ ├── arrow-down-hover.svg │ │ ├── arrow-down-pressed.svg │ │ ├── arrow-down.svg │ │ ├── arrow-left.svg │ │ ├── arrow-right.svg │ │ ├── arrow-up-disabled.svg │ │ ├── arrow-up-hover.svg │ │ ├── arrow-up-pressed.svg │ │ ├── arrow-up.svg │ │ ├── big-o.svg │ │ ├── binoculars.svg │ │ ├── check-disabled.svg │ │ ├── check-partial-disabled.svg │ │ ├── check-partial.svg │ │ ├── check.svg │ │ ├── close-hover.svg │ │ ├── close-white-hover.svg │ │ ├── close-white-pressed.svg │ │ ├── close-white.svg │ │ ├── close.svg │ │ ├── collapse.svg │ │ ├── colors-black.svg │ │ ├── colors.svg │ │ ├── crop.svg │ │ ├── csv.svg │ │ ├── delete-old.svg │ │ ├── delete.svg │ │ ├── expand.svg │ │ ├── lan.svg │ │ ├── lan_on.svg │ │ ├── list.svg │ │ ├── maximize-white-hover.svg │ │ ├── maximize-white-pressed.svg │ │ ├── maximize-white.svg │ │ ├── minimize-white-hover.svg │ │ ├── minimize-white-pressed.svg │ │ ├── minimize-white.svg │ │ ├── minimize.svg │ │ ├── off.svg │ │ ├── open-folder.svg │ │ ├── open-folder2.svg │ │ ├── play.svg │ │ ├── radio-indicator-disabled.svg │ │ ├── radio-indicator.svg │ │ ├── reload-folder2.svg │ │ ├── reload.svg │ │ ├── save.svg │ │ ├── search-next.svg │ │ ├── search-prev.svg │ │ ├── settings.svg │ │ ├── statistics.svg │ │ ├── statistics2.svg │ │ ├── stop.svg │ │ ├── to-fullscreen.svg │ │ ├── to-window.svg │ │ ├── wifi.svg │ │ ├── wifi_on.svg │ │ ├── window.svg │ │ └── yx.svg │ ├── logo.ico │ └── logo.svg ├── main.cpp ├── main_window.cpp ├── main_window.h ├── resources.qrc ├── resources.rc ├── round_progress_widget.cpp ├── round_progress_widget.h ├── socket_listener.cpp ├── socket_listener.h ├── text_highlighter.cpp ├── text_highlighter.h ├── themes │ ├── default.css │ └── default.scss ├── thread_pool.cpp ├── thread_pool.h ├── thread_pool_task.cpp ├── thread_pool_task.h ├── timer.cpp ├── timer.h ├── tree_widget_item.cpp ├── tree_widget_item.h ├── tree_widget_loader.cpp ├── tree_widget_loader.h ├── window_header.cpp └── window_header.h ├── reader ├── CMakeLists.txt └── main.cpp ├── sample ├── BUILD ├── CMakeLists.txt ├── build_express_test.sh ├── express_sample.cpp ├── main.cpp └── main_clock.cpp └── scripts ├── context_switch_logger.stp ├── make_style.sh └── test.sh /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | ColumnLimit: 100 5 | IndentWidth: 4 6 | ReflowComments: false 7 | #IndentPPDirectives: PPDIS_AfterHash #since clang 6.0 8 | ... 9 | 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.ico binary 4 | 5 | *.cpp text 6 | *.h text 7 | 8 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [yse, cas4ey] 2 | open_collective: easy_profiler 3 | custom: ["https://paypal.me/ysergey"] 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | *build* 3 | !BUILD 4 | .* 5 | *.user 6 | /*.prof 7 | .idea/ 8 | bazel* 9 | 10 | # CMake/QtCreator folders and files created on Windows 11 | CMakeFiles/ 12 | */CMakeFiles/ 13 | CMakeCache*.* 14 | Makefile* 15 | moc_*.* 16 | mocs_*.* 17 | qrc_*.* 18 | *.cmake 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | cache: ccache 3 | language: cpp 4 | jobs: 5 | include: 6 | - compiler: gcc 7 | os: linux 8 | addons: 9 | apt: 10 | sources: 11 | - ubuntu-toolchain-r-test 12 | packages: 13 | - g++-5 14 | - cmake 15 | - cmake-data 16 | - qt5-default 17 | env: 18 | -CXX_COMPILER=g++-5 19 | -C_COMPILER=gcc-5 20 | - os: osx 21 | osx_image: xcode11.4 22 | env: 23 | -CXX_COMPILER=g++-5 24 | -C_COMPILER=gcc-5 25 | -HOMEBREW_NO_AUTO_UPDATE=1 26 | script: 27 | - mkdir build 28 | - cd build 29 | - if [ "$TRAVIS_OS_NAME" = "osx" ]; then 30 | export PATH=/usr/local/opt/qt/bin:$PATH; 31 | fi 32 | - cmake -DCMAKE_CXX_COMPILER=$CXX_COMPILER -DCMAKE_C_COMPILER=$C_COMPILER .. && make -j3 33 | install: 34 | - if [ "$TRAVIS_OS_NAME" = "osx" ]; then 35 | brew install gcc5; 36 | brew install qt; 37 | brew link --force qt; 38 | fi 39 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(easy_profiler CXX) 3 | 4 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 5 | 6 | if (CMAKE_VERSION VERSION_LESS "3.1") 7 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 8 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") 9 | endif () 10 | else () 11 | set(CMAKE_CXX_STANDARD 11) 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 13 | endif () 14 | 15 | if (MSVC) 16 | if (NOT (MSVC_VERSION LESS 1914)) 17 | # turn on valid __cplusplus macro value for visual studio (available since msvc 2017 update 7) 18 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") 19 | endif () 20 | endif () 21 | 22 | option(EASY_PROFILER_NO_GUI "Build easy_profiler without the GUI application (required Qt)" OFF) 23 | 24 | set(EASY_PROGRAM_VERSION_MAJOR 2) 25 | set(EASY_PROGRAM_VERSION_MINOR 1) 26 | set(EASY_PROGRAM_VERSION_PATCH 0) 27 | set(EASY_PRODUCT_VERSION_STRING "${EASY_PROGRAM_VERSION_MAJOR}.${EASY_PROGRAM_VERSION_MINOR}.${EASY_PROGRAM_VERSION_PATCH}") 28 | 29 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) 30 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) 31 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) 32 | 33 | # set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/sdk) 34 | 35 | macro(easy_define_target_option TARGET SOURCE_OPTION TARGET_DEFINITION) 36 | if (${SOURCE_OPTION}) 37 | set(_VALUE 1) 38 | else () 39 | set(_VALUE 0) 40 | endif () 41 | target_compile_options(${TARGET} PUBLIC -D${TARGET_DEFINITION}=${_VALUE}) 42 | endmacro() 43 | 44 | SET(CMAKE_INSTALL_RPATH "$ORIGIN") 45 | 46 | add_subdirectory(easy_profiler_core) 47 | if (NOT EASY_PROFILER_NO_GUI) 48 | add_subdirectory(profiler_gui) 49 | endif() 50 | add_subdirectory(easy_profiler_converter) 51 | 52 | if (NOT EASY_PROFILER_NO_SAMPLES) 53 | add_subdirectory(sample) 54 | add_subdirectory(reader) 55 | endif () 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2021 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yse/easy_profiler/3283b7c0d3c81a1caa358e11ec3da6207ff47112/WORKSPACE -------------------------------------------------------------------------------- /appveyor.bat: -------------------------------------------------------------------------------- 1 | mkdir build_msvc 2 | cd build_msvc 3 | cmake -G "%GENERATOR%" ../ 4 | cmake --build . --config Release 5 | 6 | goto :EOF 7 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | platform: 2 | - Win64 3 | 4 | configuration: 5 | - Release 6 | 7 | environment: 8 | matrix: 9 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 10 | Qt5Widgets_DIR: "C:\\Qt\\5.5\\msvc2013_64\\lib\\cmake\\Qt5Widgets" 11 | GENERATOR: "Visual Studio 12 2013 Win64" 12 | 13 | test: off 14 | 15 | build_script: 16 | - CALL appveyor.bat 17 | 18 | skip_commits: 19 | message: /.*\[skip appveyor\].*/ 20 | -------------------------------------------------------------------------------- /easy_profiler_converter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CPP_FILES 2 | converter.cpp 3 | reader.cpp) 4 | 5 | set(HEADER_FILES 6 | converter.h 7 | reader.h) 8 | 9 | include_directories(../easy_profiler_core/) 10 | include_directories(./include) 11 | 12 | add_executable(profiler_converter ${HEADER_FILES} ${CPP_FILES} main.cpp) 13 | target_link_libraries(profiler_converter easy_profiler) 14 | 15 | install( 16 | TARGETS 17 | profiler_converter 18 | RUNTIME 19 | DESTINATION 20 | bin 21 | ) 22 | 23 | set_property(TARGET profiler_converter PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE) 24 | -------------------------------------------------------------------------------- /easy_profiler_converter/converter.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef EASY_PROFILER_CONVERTER_H 44 | #define EASY_PROFILER_CONVERTER_H 45 | 46 | #include "reader.h" 47 | #include "include/json.hpp" 48 | 49 | class EasyProfilerExporter 50 | { 51 | public: 52 | 53 | virtual ~EasyProfilerExporter() {} 54 | virtual void convert(const ::std::string& inputFile, const ::std::string& outputFile) const = 0; 55 | }; 56 | 57 | 58 | class JsonExporter EASY_FINAL : public EasyProfilerExporter 59 | { 60 | public: 61 | 62 | ~JsonExporter() override {} 63 | void convert(const ::std::string& inputFile, const ::std::string& outputFile) const override; 64 | 65 | private: 66 | 67 | void convert(const profiler::reader::BlocksTreeNode& node, nlohmann::json& json) const; 68 | void convertChildren(const profiler::reader::BlocksTreeNode& node, nlohmann::json& json) const; 69 | 70 | }; // end of class JsonExporter. 71 | 72 | #endif //EASY_PROFILER_CONVERTER_H 73 | -------------------------------------------------------------------------------- /easy_profiler_converter/main.cpp: -------------------------------------------------------------------------------- 1 | ///std 2 | #include 3 | #include 4 | #include "converter.h" 5 | 6 | using namespace profiler::reader; 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | std::string filename, output_json_filename; 11 | 12 | if (argc > 1 && argv[1]) 13 | { 14 | filename = argv[1]; 15 | } 16 | else 17 | { 18 | std::cout << "Usage: " << argv[0] << " INPUT_PROF_FILE [OUTPUT_JSON_FILE]\n" 19 | "where:\n" 20 | "INPUT_PROF_FILE // Required\n" 21 | "OUTPUT_JSON_FILE (if not specified output will be print in stdout) // Optional\n"; 22 | return 1; 23 | } 24 | 25 | if (argc > 2 && argv[2]) 26 | { 27 | output_json_filename = argv[2]; 28 | } 29 | 30 | JsonExporter js; 31 | js.convert(filename, output_json_filename); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /easy_profiler_core/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "easy_profiler", 3 | srcs = glob(["**/*.cpp", "**/*.h"]), 4 | hdrs = glob(["include/**"]), 5 | includes = ["include", "."], 6 | visibility = ["//visibility:public"], 7 | defines = [ 8 | "EASY_PROFILER_VERSION_MAJOR=2", 9 | "EASY_PROFILER_VERSION_MINOR=1", 10 | "EASY_PROFILER_VERSION_PATCH=0", 11 | "BUILD_WITH_EASY_PROFILER=1", 12 | ] 13 | ) -------------------------------------------------------------------------------- /easy_profiler_core/LICENSE.MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 15 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 16 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 17 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 18 | USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /easy_profiler_core/base_block_descriptor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #include 44 | 45 | namespace profiler 46 | { 47 | 48 | BaseBlockDescriptor::BaseBlockDescriptor(block_id_t _id, EasyBlockStatus _status, int _line, 49 | block_type_t _block_type, color_t _color) EASY_NOEXCEPT 50 | : m_id(_id) 51 | , m_line(_line) 52 | , m_type(_block_type) 53 | , m_color(_color) 54 | , m_status(_status) 55 | { 56 | 57 | } 58 | 59 | } // end of namespace profiler. 60 | -------------------------------------------------------------------------------- /easy_profiler_core/block_descriptor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #include 44 | #include "block_descriptor.h" 45 | 46 | #if EASY_BLOCK_DESC_FULL_COPY == 0 47 | # define EASY_BLOCK_DESC_STRING_LEN(s) static_cast(strlen(s) + 1) 48 | # define EASY_BLOCK_DESC_STRING_VAL(s) s 49 | #else 50 | # define EASY_BLOCK_DESC_STRING_LEN(s) static_cast(s.size() + 1) 51 | # define EASY_BLOCK_DESC_STRING_VAL(s) s.c_str() 52 | #endif 53 | 54 | BlockDescriptor::BlockDescriptor(profiler::block_id_t _id, profiler::EasyBlockStatus _status, const char* _name, 55 | const char* _filename, int _line, profiler::block_type_t _block_type, 56 | profiler::color_t _color) 57 | : Parent(_id, _status, _line, _block_type, _color) 58 | , m_filename(_filename) 59 | , m_name(_name) 60 | { 61 | } 62 | 63 | const char* BlockDescriptor::name() const 64 | { 65 | return EASY_BLOCK_DESC_STRING_VAL(m_name); 66 | } 67 | 68 | const char* BlockDescriptor::filename() const 69 | { 70 | return EASY_BLOCK_DESC_STRING_VAL(m_filename); 71 | } 72 | 73 | uint16_t BlockDescriptor::nameSize() const 74 | { 75 | return EASY_BLOCK_DESC_STRING_LEN(m_name); 76 | } 77 | 78 | uint16_t BlockDescriptor::filenameSize() const 79 | { 80 | return EASY_BLOCK_DESC_STRING_LEN(m_filename); 81 | } 82 | 83 | void BlockDescriptor::destroy(BlockDescriptor* instance) 84 | { 85 | #if EASY_BLOCK_DESC_FULL_COPY == 0 86 | if (instance != nullptr) 87 | instance->~BlockDescriptor(); 88 | free(instance); 89 | #else 90 | delete instance; 91 | #endif 92 | } 93 | -------------------------------------------------------------------------------- /easy_profiler_core/block_descriptor.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef EASY_PROFILER_BLOCK_DESCRIPTOR_H 44 | #define EASY_PROFILER_BLOCK_DESCRIPTOR_H 45 | 46 | #include 47 | #include 48 | 49 | #ifndef EASY_BLOCK_DESC_FULL_COPY 50 | # define EASY_BLOCK_DESC_FULL_COPY 1 51 | #endif 52 | 53 | class BlockDescriptor : public profiler::BaseBlockDescriptor 54 | { 55 | friend ProfileManager; 56 | 57 | using Parent = profiler::BaseBlockDescriptor; 58 | 59 | #if EASY_BLOCK_DESC_FULL_COPY == 0 60 | using string_t = const char*; 61 | #else 62 | using string_t = std::string; 63 | #endif 64 | 65 | string_t m_filename; ///< Source file name where this block is declared 66 | string_t m_name; ///< Static name of all blocks of the same type (blocks can have dynamic name) which is, in pair with descriptor id, a unique block identifier 67 | 68 | public: 69 | 70 | BlockDescriptor() = delete; 71 | BlockDescriptor(const BlockDescriptor&) = delete; 72 | BlockDescriptor& operator = (const BlockDescriptor&) = delete; 73 | 74 | BlockDescriptor(profiler::block_id_t _id, profiler::EasyBlockStatus _status, const char* _name, 75 | const char* _filename, int _line, profiler::block_type_t _block_type, profiler::color_t _color); 76 | 77 | const char* name() const; 78 | const char* filename() const; 79 | uint16_t nameSize() const; 80 | uint16_t filenameSize() const; 81 | 82 | static void destroy(BlockDescriptor* instance); 83 | 84 | }; // END of class BlockDescriptor. 85 | 86 | #endif //EASY_PROFILER_BLOCK_DESCRIPTOR_H 87 | -------------------------------------------------------------------------------- /easy_profiler_core/cmake/config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 4 | check_required_components("@PROJECT_NAME@") 5 | -------------------------------------------------------------------------------- /easy_profiler_core/cmake/qnx-aarch64.cmake: -------------------------------------------------------------------------------- 1 | # Processor specification, possible values: x86_64, armv7le, aarach64, ... 2 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 3 | # Specify arch to be aarch64le 4 | set(arch gcc_ntoaarch64le) 5 | set(ARCH_NAME aarch64le) 6 | 7 | # Command settings for QNX 8 | include(${CMAKE_CURRENT_LIST_DIR}/qnx.cmake) 9 | -------------------------------------------------------------------------------- /easy_profiler_core/cmake/qnx-armv7.cmake: -------------------------------------------------------------------------------- 1 | # Processor specification, possible values: x86_64, armv7le, aarach64, ... 2 | set(CMAKE_SYSTEM_PROCESSOR armv7) 3 | # Specify arch to be armv7le 4 | set(arch gcc_ntoarmv7le) 5 | set(ARCH_NAME armle-v7) 6 | 7 | # Command settings for QNX 8 | include(${CMAKE_CURRENT_LIST_DIR}/qnx.cmake) 9 | -------------------------------------------------------------------------------- /easy_profiler_core/cmake/qnx-x86_64.cmake: -------------------------------------------------------------------------------- 1 | # Processor specification, possible values: x86_64, armv7le, aarach64, ... 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | # Specify arch to be x86_64 4 | set(arch gcc_ntox86_64) 5 | set(ARCH_NAME x86_64) 6 | 7 | # Command settings for QNX 8 | include(${CMAKE_CURRENT_LIST_DIR}/qnx.cmake) 9 | -------------------------------------------------------------------------------- /easy_profiler_core/cmake/qnx.cmake: -------------------------------------------------------------------------------- 1 | # Cross compilation for QNX 2 | set(CMAKE_SYSTEM_NAME QNX) 3 | set(QNX YES) 4 | 5 | # Suppose you have already set QNX_HOST and QNX_TARGET Add compiler and linker 6 | # flags -std=gnu++14 is needed because QNX header files only cover GNU and POSIX 7 | set(CMAKE_CXX_FLAGS 8 | "${CMAKE_EXE_LINKER_FLAGS} -lang-c++ -V${arch} -std=gnu++14") 9 | 10 | # Add definitions command for diffent platforms So we can use macro definition 11 | # "#ifdef PLATFORM_QNX" in source code 12 | set(PLATFORM_QNX ON) 13 | add_definitions(-DPLATFORM_QNX) 14 | # Build crossguid library for qnx 15 | set(GUID_LIBUUID ON) 16 | add_definitions(-DGUID_LIBUUID) 17 | 18 | # Upstream settings 19 | set(CMAKE_C_COMPILER qcc) 20 | set(CMAKE_C_COMPILER_TARGET ${arch}) 21 | set(CMAKE_CXX_COMPILER q++) 22 | set(CMAKE_CXX_COMPILER_TARGET ${arch}) 23 | 24 | # Set the path to the qnx host include and lib 25 | include_directories($ENV{QNX_HOST}/usr/include) 26 | link_directories($ENV{QNX_HOST}/usr/lib) 27 | 28 | # Set the path to the qnx target include and lib 29 | include_directories($ENV{QNX_TARGET}/usr/include) 30 | link_directories($ENV{QNX_TARGET}/usr/lib) 31 | include_directories($ENV{QNX_TARGET}/${ARCH_NAME}/usr/include) 32 | link_directories($ENV{QNX_TARGET}/${ARCH_NAME}/lib) 33 | link_directories($ENV{QNX_TARGET}/${ARCH_NAME}/usr/lib) 34 | -------------------------------------------------------------------------------- /easy_profiler_core/current_thread.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef EASY_PROFILER_CURRENT_THREAD_H 44 | #define EASY_PROFILER_CURRENT_THREAD_H 45 | 46 | #include 47 | 48 | #ifdef _WIN32 49 | # include 50 | #elif defined(__APPLE__) 51 | # include 52 | # include 53 | #elif defined(__QNX__) 54 | # include 55 | # include 56 | # define __NR_gettid SYS_gettid 57 | #else 58 | # include 59 | # include 60 | # include 61 | #endif 62 | 63 | inline profiler::thread_id_t getCurrentThreadId() 64 | { 65 | #ifdef _WIN32 66 | return (profiler::thread_id_t)::GetCurrentThreadId(); 67 | #elif defined(__APPLE__) 68 | # if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6) || \ 69 | (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0) 70 | static EASY_THREAD_LOCAL uint64_t _id = 0; 71 | if (!_id) 72 | pthread_threadid_np(NULL, &_id); 73 | return (profiler::thread_id_t)_id; 74 | # else 75 | return (profiler::thread_id_t)pthread_self(); 76 | # endif 77 | #elif defined(__QNX__) 78 | EASY_THREAD_LOCAL static const profiler::thread_id_t _id = (profiler::thread_id_t)gettid(); 79 | return _id; 80 | #elif defined(__EMSCRIPTEN__) 81 | EASY_THREAD_LOCAL static const profiler::thread_id_t _id = static_cast(pthread_self()); 82 | return _id; 83 | #else 84 | EASY_THREAD_LOCAL static const profiler::thread_id_t _id = (profiler::thread_id_t)syscall(__NR_gettid); 85 | return _id; 86 | #endif 87 | } 88 | 89 | #endif // EASY_PROFILER_CURRENT_THREAD_H 90 | -------------------------------------------------------------------------------- /easy_profiler_core/event_trace_status.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ifndef EASY_PROFILER__EVENT_TRACE_STATUS__H_ 5 | #define EASY_PROFILER__EVENT_TRACE_STATUS__H_ 6 | 7 | ////////////////////////////////////////////////////////////////////////// 8 | ////////////////////////////////////////////////////////////////////////// 9 | 10 | enum class EventTracingEnableStatus : unsigned char 11 | { 12 | LaunchedSuccessfully = 0, 13 | PermissionDenied, 14 | AlreadyLaunched, 15 | BadPropertiesSize, 16 | OpenTraceFailed, 17 | UnknownError, 18 | }; 19 | 20 | ////////////////////////////////////////////////////////////////////////// 21 | ////////////////////////////////////////////////////////////////////////// 22 | 23 | #endif // EASY_PROFILER__EVENT_TRACE_STATUS__H_ 24 | -------------------------------------------------------------------------------- /easy_profiler_core/include/easy/details/arbitrary_value_public_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef EASY_PROFILER_ARBITRARY_VALUE_PUBLIC_TYPES_H 44 | #define EASY_PROFILER_ARBITRARY_VALUE_PUBLIC_TYPES_H 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | namespace profiler 52 | { 53 | 54 | enum class DataType : uint8_t 55 | { 56 | Bool = 0, 57 | Char, 58 | Int8, 59 | Uint8, 60 | Int16, 61 | Uint16, 62 | Int32, 63 | Uint32, 64 | Int64, 65 | Uint64, 66 | Float, 67 | Double, 68 | String, 69 | 70 | TypesCount 71 | }; // end of enum class DataType. 72 | 73 | template struct StdType; 74 | 75 | template struct StdToDataType EASY_FINAL { 76 | EASY_STATIC_CONSTEXPR auto data_type = DataType::TypesCount; 77 | }; 78 | 79 | # define EASY_DATATYPE_CONVERSION(DataTypeName, StdTypeName)\ 80 | template <> struct StdType EASY_FINAL { using value_type = StdTypeName; };\ 81 | template <> struct StdToDataType EASY_FINAL { EASY_STATIC_CONSTEXPR auto data_type = DataTypeName; } 82 | 83 | EASY_DATATYPE_CONVERSION(DataType::Bool , bool ); 84 | EASY_DATATYPE_CONVERSION(DataType::Char , char ); 85 | EASY_DATATYPE_CONVERSION(DataType::Int8 , int8_t ); 86 | EASY_DATATYPE_CONVERSION(DataType::Uint8 , uint8_t ); 87 | EASY_DATATYPE_CONVERSION(DataType::Int16 , int16_t ); 88 | EASY_DATATYPE_CONVERSION(DataType::Uint16, uint16_t); 89 | EASY_DATATYPE_CONVERSION(DataType::Int32 , int32_t ); 90 | EASY_DATATYPE_CONVERSION(DataType::Uint32, uint32_t); 91 | EASY_DATATYPE_CONVERSION(DataType::Int64 , int64_t ); 92 | EASY_DATATYPE_CONVERSION(DataType::Uint64, uint64_t); 93 | EASY_DATATYPE_CONVERSION(DataType::Float , float ); 94 | EASY_DATATYPE_CONVERSION(DataType::Double, double ); 95 | 96 | # undef EASY_DATATYPE_CONVERSION 97 | 98 | template <> struct StdType EASY_FINAL { using value_type = char; }; 99 | template <> struct StdToDataType EASY_FINAL { EASY_STATIC_CONSTEXPR auto data_type = DataType::String; }; 100 | 101 | } // end of namespace profiler. 102 | 103 | #endif //EASY_PROFILER_ARBITRARY_VALUE_PUBLIC_TYPES_H 104 | -------------------------------------------------------------------------------- /easy_profiler_core/include/easy/details/profiler_in_use.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef EASY_PROFILER_IN_USE_H 44 | #define EASY_PROFILER_IN_USE_H 45 | 46 | // 47 | // BUILD_WITH_EASY_PROFILER is defined in CMakeLists.txt if your project is linked to easy_profiler. 48 | // 49 | 50 | // 51 | // DISABLE_EASY_PROFILER may be defined manually in source-file before #include 52 | // to disable profiler for certain source-file or project. 53 | // 54 | 55 | #if defined(BUILD_WITH_EASY_PROFILER) && !defined(DISABLE_EASY_PROFILER) 56 | 57 | /** 58 | \defgroup profiler EasyProfiler 59 | */ 60 | 61 | 62 | /** Indicates that EasyProfiler is used. 63 | 64 | \ingroup profiler 65 | */ 66 | # define USING_EASY_PROFILER 67 | 68 | #endif 69 | 70 | #endif // EASY_PROFILER_IN_USE_H 71 | -------------------------------------------------------------------------------- /easy_profiler_core/include/easy/easy_protocol.h: -------------------------------------------------------------------------------- 1 | #ifndef EASY_PROPROTOCOL_H 2 | #define EASY_PROPROTOCOL_H 3 | ///C++ 4 | #include 5 | #include 6 | #include 7 | 8 | ///this 9 | #include 10 | //#include 11 | 12 | ///for actual version vistit https://github.com/yse/easy_profiler/wiki/.prof-file-format-v1.3.0 13 | 14 | namespace profiler { 15 | 16 | namespace reader { 17 | 18 | struct BlockDescriptor; 19 | 20 | struct BlocksInfo //12 21 | { 22 | uint32_t totalBlocksCount; //4 bytes 23 | uint64_t totalBlocksMemory; //8 bytes 24 | }; 25 | 26 | struct DescriptorsInfo //12 27 | { 28 | uint32_t allDescriptorsCount; //4 bytes 29 | uint64_t allDescriptorsMemory; //8 bytes 30 | }; 31 | 32 | struct FileHeader //64 33 | { 34 | uint32_t signature; //4 35 | uint32_t version; //4 36 | uint64_t processId; //8 37 | int64_t cpuFrequency; //8 38 | uint64_t beginTime; //8 39 | uint64_t endTime; //8 40 | BlocksInfo serializedBlocksInfo; //12 41 | DescriptorsInfo blocksDescriptorInfo; //12 42 | }; 43 | 44 | struct BlockInfo 45 | { 46 | uint64_t beginTime; 47 | uint64_t endTime; 48 | const BlockDescriptor* descriptor; 49 | uint32_t blockIndex; 50 | }; 51 | 52 | struct ContextSwitchEvent 53 | { 54 | uint64_t beginTime; 55 | uint64_t endTime; 56 | uint64_t targetThreadId; 57 | std::string targetProcess; ///< Contains process id and process name 58 | }; 59 | 60 | struct BlockDescriptor 61 | { 62 | uint32_t parentId; ///< This will differ from id if this descriptor was created from runtime named block 63 | uint32_t id; 64 | int lineNumber; 65 | uint32_t argbColor; 66 | uint8_t blockType; 67 | uint8_t status; 68 | std::string blockName; 69 | std::string fileName; 70 | }; 71 | 72 | } //namespace reader 73 | 74 | } //namespace profiler 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /easy_profiler_core/include/easy/easy_socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | #ifndef EASY_PROFILER_SOCKET_H 43 | #define EASY_PROFILER_SOCKET_H 44 | 45 | #include 46 | #include 47 | 48 | #ifndef _WIN32 49 | 50 | // Unix 51 | # include 52 | # include 53 | # include 54 | # include 55 | # include 56 | # include 57 | # include //for android-build 58 | 59 | #else 60 | 61 | // Windows 62 | #ifndef WIN32_LEAN_AND_MEAN 63 | #define WIN32_LEAN_AND_MEAN 64 | #endif 65 | # include 66 | # include 67 | # include 68 | # include 69 | 70 | #endif 71 | 72 | class PROFILER_API EasySocket EASY_FINAL 73 | { 74 | public: 75 | 76 | #ifdef _WIN32 77 | typedef SOCKET socket_t; 78 | #else 79 | typedef int socket_t; 80 | #endif 81 | 82 | enum class ConnectionState : int8_t 83 | { 84 | Disconnected = -1, 85 | Unknown, 86 | Connected, 87 | Connecting 88 | }; 89 | 90 | private: 91 | 92 | socket_t m_socket = 0; 93 | socket_t m_replySocket = 0; 94 | int m_wsaret = -1; 95 | 96 | struct hostent* m_server = nullptr; 97 | struct sockaddr_in m_serverAddress; 98 | 99 | ConnectionState m_state = ConnectionState::Unknown; 100 | 101 | public: 102 | 103 | EasySocket(); 104 | ~EasySocket(); 105 | 106 | void setReceiveTimeout(int milliseconds); 107 | 108 | int send(const void* buf, size_t nbyte); 109 | int receive(void* buf, size_t nbyte); 110 | int listen(int count = 5); 111 | int accept(); 112 | int bind(uint16_t portno); 113 | 114 | bool setAddress(const char* serv, uint16_t port); 115 | int connect(); 116 | 117 | void flush(); 118 | void init(); 119 | 120 | ConnectionState state() const; 121 | bool isDisconnected() const; 122 | bool isConnected() const; 123 | 124 | private: 125 | 126 | void checkResult(int result); 127 | bool checkSocket(socket_t s) const; 128 | void setBlocking(socket_t s, bool blocking); 129 | 130 | }; // end of class EasySocket. 131 | 132 | #endif // EASY_PROFILER_SOCKET_H 133 | -------------------------------------------------------------------------------- /easy_profiler_core/include/easy/utility.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef EASY_PROFILER_UTILITY_H 4 | #define EASY_PROFILER_UTILITY_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace estd { 12 | 13 | ////////////////////////////////////////////////////////////////////////// 14 | 15 | namespace detail { 16 | template struct hasher { 17 | using type = const T&; 18 | EASY_FORCE_INLINE size_t operator () (type value) const { return ::std::hash {}(value); } }; 19 | 20 | template struct hasher { 21 | using type = T; 22 | EASY_FORCE_INLINE size_t operator () (type value) const { return static_cast(value); } }; 23 | } 24 | 25 | template struct hash EASY_FINAL : public ::estd::detail::hasher sizeof(void*))> { 26 | using Parent = ::estd::detail::hasher sizeof(void*))>; 27 | #if defined(_MSC_VER) && _MSC_VER >= 1910 28 | // TODO: Try to compile "using Parent::operator();" in MSVC 2017 29 | size_t operator () (typename Parent::type value) const { return Parent::operator () (value); } 30 | #else 31 | using Parent::operator(); 32 | #endif 33 | }; 34 | 35 | template struct hash EASY_FINAL { 36 | EASY_FORCE_INLINE size_t operator () (const T* value) const { return reinterpret_cast(value); } }; 37 | 38 | template struct hash EASY_FINAL { 39 | EASY_FORCE_INLINE size_t operator () (const T* value) const { return reinterpret_cast(value); } }; 40 | 41 | ////////////////////////////////////////////////////////////////////////// 42 | 43 | template 44 | inline EASY_CONSTEXPR_FCN Q clamp(T min_value, Q value, W max_value) { 45 | return static_cast(min_value < value ? (value < max_value ? value : max_value) : min_value); 46 | } 47 | 48 | template 49 | EASY_FORCE_INLINE EASY_CONSTEXPR_FCN T sqr(T value) { 50 | return value * value; 51 | } 52 | 53 | template 54 | EASY_FORCE_INLINE EASY_CONSTEXPR_FCN int sign(T value) { return value < 0 ? -1 : 1; } 55 | 56 | template 57 | inline EASY_CONSTEXPR_FCN T absmin(T a, T b) { return abs(a) < abs(b) ? a : b; } 58 | 59 | template 60 | inline T logn(T value) { 61 | EASY_STATIC_CONSTEXPR double div = 1.0 / log2((double)N); 62 | return log2(value) * div; 63 | } 64 | 65 | ////////////////////////////////////////////////////////////////////////// 66 | 67 | } // end of namespace estd. 68 | 69 | #endif // EASY_PROFILER_UTILITY_H 70 | -------------------------------------------------------------------------------- /easy_profiler_core/nonscoped_block.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #include "nonscoped_block.h" 44 | #include 45 | #include 46 | 47 | NonscopedBlock::NonscopedBlock(const profiler::BaseBlockDescriptor* _desc, const char* _runtimeName, bool) 48 | : profiler::Block(_desc, _runtimeName, false), m_runtimeName(nullptr) 49 | { 50 | 51 | } 52 | 53 | NonscopedBlock::~NonscopedBlock() 54 | { 55 | // Actually destructor should not be invoked because StackBuffer do manual memory management 56 | 57 | m_end = m_begin; // to restrict profiler::Block to invoke profiler::endBlock() on destructor. 58 | free(m_runtimeName); 59 | } 60 | 61 | void NonscopedBlock::copyname() 62 | { 63 | // Here we need to copy m_name to m_runtimeName to ensure that 64 | // it would be alive to the moment we will serialize the block 65 | 66 | if ((m_status & profiler::ON) == 0) 67 | return; 68 | 69 | if (*m_name != 0) 70 | { 71 | auto len = strlen(m_name); 72 | m_runtimeName = static_cast(malloc(len + 1)); 73 | 74 | // memcpy should be faster than strncpy because we know 75 | // actual bytes number and both strings have the same size 76 | memcpy(m_runtimeName, m_name, len); 77 | 78 | m_runtimeName[len] = 0; 79 | m_name = m_runtimeName; 80 | } 81 | else 82 | { 83 | m_name = ""; 84 | } 85 | } 86 | 87 | void NonscopedBlock::destroy() 88 | { 89 | // free memory used by m_runtimeName 90 | free(m_runtimeName); 91 | m_name = ""; 92 | } 93 | -------------------------------------------------------------------------------- /easy_profiler_core/nonscoped_block.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef EASY_PROFILER_NONSCOPED_BLOCK_H 44 | #define EASY_PROFILER_NONSCOPED_BLOCK_H 45 | 46 | #include 47 | 48 | class NonscopedBlock : public profiler::Block 49 | { 50 | char* m_runtimeName; ///< A copy of _runtimeName to make it safe to begin block in one function and end it in another 51 | 52 | public: 53 | 54 | NonscopedBlock() = delete; 55 | NonscopedBlock(const NonscopedBlock&) = delete; 56 | NonscopedBlock(NonscopedBlock&&) = delete; 57 | NonscopedBlock& operator = (const NonscopedBlock&) = delete; 58 | NonscopedBlock& operator = (NonscopedBlock&&) = delete; 59 | 60 | NonscopedBlock(const profiler::BaseBlockDescriptor* _desc, const char* _runtimeName, bool = false); 61 | ~NonscopedBlock(); 62 | 63 | /** Copy string from m_name to m_runtimeName to make it safe to end block in another function. 64 | 65 | Performs any work if block is ON and m_name != "" 66 | */ 67 | void copyname(); 68 | 69 | void destroy(); 70 | 71 | }; // END of class NonscopedBlock. 72 | 73 | #endif // EASY_PROFILER_NONSCOPED_BLOCK_H 74 | -------------------------------------------------------------------------------- /easy_profiler_core/resources.rc: -------------------------------------------------------------------------------- 1 | 1 VERSIONINFO 2 | 3 | # define EASY_STRINGIFY(a) #a 4 | # define EASY_STRINGIFICATION(a) EASY_STRINGIFY(a) 5 | 6 | #define EASY_PROFILER_PRODUCT_VERSION "v" EASY_STRINGIFICATION(EASY_PROFILER_VERSION_MAJOR) "." \ 7 | EASY_STRINGIFICATION(EASY_PROFILER_VERSION_MINOR) "." \ 8 | EASY_STRINGIFICATION(EASY_PROFILER_VERSION_PATCH) 9 | 10 | FILEVERSION EASY_PROFILER_VERSION_MAJOR, EASY_PROFILER_VERSION_MINOR, EASY_PROFILER_VERSION_PATCH 11 | PRODUCTVERSION EASY_PROFILER_VERSION_MAJOR, EASY_PROFILER_VERSION_MINOR, EASY_PROFILER_VERSION_PATCH 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "080904b0" 16 | BEGIN 17 | VALUE "CompanyName", "EasySolutions" 18 | VALUE "FileDescription", "Lightweight profiler library for C++" 19 | VALUE "LegalCopyright", "Copyright (C) 2016-2019 Victor Zarubkin, Sergey Yagovtsev" 20 | VALUE "LegalTrademarks1", "All Rights Reserved" 21 | VALUE "LegalTrademarks2", "All Rights Reserved" 22 | VALUE "ProductName", "easy_profiler lib" 23 | VALUE "ProductVersion", EASY_PROFILER_PRODUCT_VERSION 24 | END 25 | END 26 | BLOCK "VarFileInfo" 27 | BEGIN 28 | VALUE "Translation", 0x809, 1200 29 | END 30 | END 31 | -------------------------------------------------------------------------------- /easy_profiler_core/serialized_block.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #include 44 | #include 45 | #include "thread_storage.h" 46 | 47 | namespace profiler 48 | { 49 | 50 | SerializedBlock::SerializedBlock(const Block& block, uint16_t name_length) 51 | : BaseBlockData(block) 52 | { 53 | char* pName = const_cast(name()); 54 | if (name_length != 0) 55 | strncpy(pName, block.name(), name_length); 56 | pName[name_length] = 0; 57 | } 58 | 59 | SerializedCSwitch::SerializedCSwitch(const CSwitchBlock& block, uint16_t name_length) 60 | : CSwitchEvent(block) 61 | { 62 | char* pName = const_cast(name()); 63 | if (name_length != 0) 64 | strncpy(pName, block.name(), name_length); 65 | pName[name_length] = 0; 66 | } 67 | 68 | } // end of namespace profiler. 69 | -------------------------------------------------------------------------------- /easy_profiler_core/spin_lock.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef EASY_PROFILER_SPIN_LOCK_H 44 | #define EASY_PROFILER_SPIN_LOCK_H 45 | 46 | #define EASY_USE_CRITICAL_SECTION // Use CRITICAL_SECTION instead of std::atomic_flag 47 | 48 | #if defined(_WIN32) && defined(EASY_USE_CRITICAL_SECTION) 49 | #include 50 | #else 51 | #include 52 | #endif 53 | 54 | namespace profiler { 55 | 56 | #if defined(_WIN32) && defined(EASY_USE_CRITICAL_SECTION) 57 | // std::atomic_flag on Windows works slower than critical section, so we will use it instead of std::atomic_flag... 58 | // By the way, Windows critical sections are slower than std::atomic_flag on Unix. 59 | class spin_lock { CRITICAL_SECTION m_lock; public: 60 | 61 | void lock() { 62 | EnterCriticalSection(&m_lock); 63 | } 64 | 65 | void unlock() { 66 | LeaveCriticalSection(&m_lock); 67 | } 68 | 69 | spin_lock() { 70 | InitializeCriticalSection(&m_lock); 71 | } 72 | 73 | ~spin_lock() { 74 | DeleteCriticalSection(&m_lock); 75 | } 76 | }; 77 | #else 78 | // std::atomic_flag on Unix works fine and very fast (almost instant!) 79 | class spin_lock { ::std::atomic_flag m_lock; public: 80 | 81 | void lock() { 82 | while (m_lock.test_and_set(::std::memory_order_acquire)); 83 | } 84 | 85 | void unlock() { 86 | m_lock.clear(::std::memory_order_release); 87 | } 88 | 89 | spin_lock() { 90 | m_lock.clear(); 91 | } 92 | }; 93 | #endif 94 | 95 | template 96 | class guard_lock 97 | { 98 | T& m_lock; 99 | bool m_isLocked = false; 100 | 101 | public: 102 | 103 | explicit guard_lock(T& m) : m_lock(m) { 104 | m_lock.lock(); 105 | m_isLocked = true; 106 | } 107 | 108 | ~guard_lock() { 109 | unlock(); 110 | } 111 | 112 | inline void unlock() { 113 | if (m_isLocked) { 114 | m_lock.unlock(); 115 | m_isLocked = false; 116 | } 117 | } 118 | }; 119 | 120 | } // END of namespace profiler. 121 | 122 | #ifdef EASY_USE_CRITICAL_SECTION 123 | # undef EASY_USE_CRITICAL_SECTION 124 | #endif 125 | 126 | #endif // EASY_PROFILER_SPIN_LOCK_H 127 | -------------------------------------------------------------------------------- /mit.lic: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 15 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 16 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 17 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 18 | USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /profiler_gui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #set(CMAKE_PREFIX_PATH f:/qt/5.5/5.6/msvc2013_64/lib/cmake) 2 | 3 | set(CMAKE_AUTOMOC ON) 4 | set(CMAKE_AUTORCC ON) 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | find_package(Qt6Widgets) 8 | find_package(Qt6Core5Compat) 9 | 10 | if (Qt6Widgets_FOUND) 11 | message(STATUS "Using Qt v${Qt6Widgets_VERSION}") 12 | if (NOT("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") AND WIN32) 13 | set(APPLICATION_PLATFORM WIN32) 14 | endif () 15 | add_executable(profiler_gui ${APPLICATION_PLATFORM} 16 | main.cpp 17 | arbitrary_value_inspector.h 18 | arbitrary_value_inspector.cpp 19 | arbitrary_value_tooltip.h 20 | arbitrary_value_tooltip.cpp 21 | blocks_graphics_view.h 22 | blocks_graphics_view.cpp 23 | blocks_tree_widget.h 24 | blocks_tree_widget.cpp 25 | bookmarks_editor.h 26 | bookmarks_editor.cpp 27 | common_functions.h 28 | common_functions.cpp 29 | common_types.h 30 | descriptors_tree_widget.h 31 | descriptors_tree_widget.cpp 32 | dialog.h 33 | dialog.cpp 34 | file_reader.h 35 | file_reader.cpp 36 | fps_widget.h 37 | fps_widget.cpp 38 | globals.h 39 | globals.cpp 40 | globals_qobjects.cpp 41 | graphics_block_item.h 42 | graphics_block_item.cpp 43 | graphics_image_item.h 44 | graphics_image_item.cpp 45 | graphics_ruler_item.h 46 | graphics_ruler_item.cpp 47 | graphics_scrollbar.h 48 | graphics_scrollbar.cpp 49 | graphics_slider_area.h 50 | graphics_slider_area.cpp 51 | main_window.h 52 | main_window.cpp 53 | round_progress_widget.h 54 | round_progress_widget.cpp 55 | socket_listener.h 56 | socket_listener.cpp 57 | text_highlighter.h 58 | text_highlighter.cpp 59 | timer.h 60 | timer.cpp 61 | thread_pool.h 62 | thread_pool.cpp 63 | thread_pool_task.h 64 | thread_pool_task.cpp 65 | tree_widget_item.h 66 | tree_widget_item.cpp 67 | tree_widget_loader.h 68 | tree_widget_loader.cpp 69 | window_header.h 70 | window_header.cpp 71 | resources.qrc 72 | resources.rc 73 | ) 74 | target_link_libraries(profiler_gui Qt6::Widgets Qt6::Core5Compat easy_profiler) 75 | if (WIN32) 76 | target_compile_definitions(profiler_gui PRIVATE -D_WIN32_WINNT=0x0600) 77 | endif () 78 | if (MINGW) 79 | target_compile_definitions(profiler_gui PRIVATE -DSTRSAFE_NO_DEPRECATE) 80 | endif () 81 | 82 | install( 83 | TARGETS 84 | profiler_gui 85 | RUNTIME 86 | DESTINATION 87 | bin 88 | ) 89 | 90 | set_property(TARGET profiler_gui PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE) 91 | else () 92 | message(STATUS "INFO\n\n\tQt6 not found! Generating EasyProfiler projects without GUI.\n") 93 | endif () 94 | 95 | -------------------------------------------------------------------------------- /profiler_gui/arbitrary_value_tooltip.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : arbitrary_value_tooltip.h 3 | * ----------------- : 4 | * creation time : 2018/03/25 5 | * author : Victor Zarubkin 6 | * email : v.s.zarubkin@gmail.com 7 | * ----------------- : 8 | * description : The file contains declaration of ArbitraryValueToolTip which is used 9 | * : for displaying arbitrary value in Diagram and StatsTree widgets. 10 | * ----------------- : 11 | * license : Lightweight profiler library for c++ 12 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 13 | * : 14 | * : Licensed under either of 15 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 16 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 17 | * : at your option. 18 | * : 19 | * : The MIT License 20 | * : 21 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 22 | * : of this software and associated documentation files (the "Software"), to deal 23 | * : in the Software without restriction, including without limitation the rights 24 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 25 | * : of the Software, and to permit persons to whom the Software is furnished 26 | * : to do so, subject to the following conditions: 27 | * : 28 | * : The above copyright notice and this permission notice shall be included in all 29 | * : copies or substantial portions of the Software. 30 | * : 31 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 32 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 33 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 34 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 35 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 36 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | * : 38 | * : The Apache License, Version 2.0 (the "License") 39 | * : 40 | * : You may not use this file except in compliance with the License. 41 | * : You may obtain a copy of the License at 42 | * : 43 | * : http://www.apache.org/licenses/LICENSE-2.0 44 | * : 45 | * : Unless required by applicable law or agreed to in writing, software 46 | * : distributed under the License is distributed on an "AS IS" BASIS, 47 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 48 | * : See the License for the specific language governing permissions and 49 | * : limitations under the License. 50 | ************************************************************************/ 51 | 52 | #ifndef EASY_PROFILER_ARBITRARY_VALUE_TOOLTIP_H 53 | #define EASY_PROFILER_ARBITRARY_VALUE_TOOLTIP_H 54 | 55 | #include 56 | #include 57 | #include 58 | 59 | class ArbitraryValueToolTip : public QWidget 60 | { 61 | Q_OBJECT 62 | 63 | public: 64 | 65 | explicit ArbitraryValueToolTip(const QString& _name, const profiler::BlocksTree& _block, QWidget* _parent = nullptr); 66 | ~ArbitraryValueToolTip() override; 67 | }; 68 | 69 | #endif //EASY_PROFILER_ARBITRARY_VALUE_TOOLTIP_H 70 | -------------------------------------------------------------------------------- /profiler_gui/bookmarks_editor.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : bookmarks_editor.h 3 | * ----------------- : 4 | * creation time : 2018/06/03 5 | * author : Victor Zarubkin 6 | * email : v.s.zarubkin@gmail.com 7 | * ----------------- : 8 | * description : The file contains declaration of BookmarkEditor. 9 | * ----------------- : 10 | * license : Lightweight profiler library for c++ 11 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 12 | * : 13 | * : Licensed under either of 14 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 15 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 16 | * : at your option. 17 | * : 18 | * : The MIT License 19 | * : 20 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 21 | * : of this software and associated documentation files (the "Software"), to deal 22 | * : in the Software without restriction, including without limitation the rights 23 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 24 | * : of the Software, and to permit persons to whom the Software is furnished 25 | * : to do so, subject to the following conditions: 26 | * : 27 | * : The above copyright notice and this permission notice shall be included in all 28 | * : copies or substantial portions of the Software. 29 | * : 30 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 31 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 32 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 33 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 34 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 35 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | * : 37 | * : The Apache License, Version 2.0 (the "License") 38 | * : 39 | * : You may not use this file except in compliance with the License. 40 | * : You may obtain a copy of the License at 41 | * : 42 | * : http://www.apache.org/licenses/LICENSE-2.0 43 | * : 44 | * : Unless required by applicable law or agreed to in writing, software 45 | * : distributed under the License is distributed on an "AS IS" BASIS, 46 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 47 | * : See the License for the specific language governing permissions and 48 | * : limitations under the License. 49 | ************************************************************************/ 50 | 51 | #ifndef EASY_PROFILER_BOOKMARKS_EDITOR_H 52 | #define EASY_PROFILER_BOOKMARKS_EDITOR_H 53 | 54 | #include 55 | 56 | class BookmarkEditor : public QDialog 57 | { 58 | Q_OBJECT; 59 | 60 | using This = BookmarkEditor; 61 | using Parent = QDialog; 62 | 63 | class QTextEdit* m_textEdit; 64 | class QPushButton* m_colorButton; 65 | const size_t m_bookmarkIndex; 66 | const bool m_isNewBookmark; 67 | 68 | public: 69 | 70 | explicit BookmarkEditor(size_t bookmarkIndex, bool isNew, QWidget* parent = nullptr); 71 | ~BookmarkEditor() override; 72 | 73 | signals: 74 | 75 | void bookmarkRemoved(size_t index); 76 | 77 | private slots: 78 | 79 | void onSaveClicked(bool); 80 | void onDeleteClicked(bool); 81 | void onColorButtonClicked(bool); 82 | void onReject(); 83 | 84 | private: 85 | 86 | void loadSettings(); 87 | void saveSettings(); 88 | 89 | }; // class BookmarkEditor. 90 | 91 | #endif // EASY_PROFILER_BOOKMARKS_EDITOR_H 92 | -------------------------------------------------------------------------------- /profiler_gui/complexity_calculator.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef COMPLEXITY_CALCULATOR_H 44 | #define COMPLEXITY_CALCULATOR_H 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | enum class ComplexityType : uint8_t 53 | { 54 | Constant = 0, ///< O(1) 55 | Logarithmic, ///< O(logN) 56 | Linear, ///< O(N) 57 | Quasilinear, ///< O(N*logN) 58 | Quadratic, ///< O(N^2) 59 | Cubic, ///< O(N^3) 60 | Exponential, ///< O(2^N) 61 | Factorial, ///< O(N!) 62 | Unknown, ///< cannot estimate 63 | }; 64 | 65 | template 66 | TValue getAverage(const std::vector& derivatives) 67 | { 68 | TValue result = std::accumulate(derivatives.begin(), derivatives.end(), TValue(0.0), [](TValue a, TValue b) 69 | { 70 | if (std::isnormal(b)) 71 | return a + b; 72 | return a; 73 | }); 74 | 75 | return result / TValue(derivatives.size()); 76 | } 77 | 78 | template 79 | std::vector calculateDerivatives(const std::map& input_array) 80 | { 81 | std::vector result; 82 | 83 | for (auto it = input_array.cbegin(), next_it = input_array.cbegin()++; next_it != input_array.cend(); it = next_it, ++next_it) 84 | { 85 | const auto x0 = it->first; 86 | const auto x1 = next_it->first; 87 | 88 | const auto y0 = it->second; 89 | const auto y1 = next_it->second; 90 | 91 | result.push_back((y1 - y0) / (x1 - x0)); 92 | } 93 | 94 | return result; 95 | } 96 | 97 | template 98 | std::map getLogarithmicChart(const std::map >& input) 99 | { 100 | std::map result; 101 | 102 | for (auto it : input) 103 | { 104 | result[static_cast(std::log2(it.first))] = std::log2(getAverage(it.second)); 105 | } 106 | 107 | return result; 108 | } 109 | 110 | template 111 | ComplexityType estimateComplexity(const std::map >& input) 112 | { 113 | const auto average = getAverage(calculateDerivatives(getLogarithmicChart(input))); 114 | const double estimate_angle = std::atan(double(average)) * 57.3; 115 | 116 | if (estimate_angle < 1) 117 | return ComplexityType::Constant; 118 | 119 | if (estimate_angle < 10) 120 | return ComplexityType::Logarithmic; 121 | 122 | if (estimate_angle < 30) 123 | return ComplexityType::Linear; 124 | 125 | if (estimate_angle < 50) 126 | return ComplexityType::Quasilinear; 127 | 128 | if (estimate_angle < 65) 129 | return ComplexityType::Quadratic; 130 | 131 | if (estimate_angle < 70) 132 | return ComplexityType::Cubic; 133 | 134 | if (estimate_angle < 85) 135 | return ComplexityType::Exponential; 136 | 137 | return ComplexityType::Factorial; 138 | } 139 | 140 | #endif // COMPLEXITY_CALCULATOR_H 141 | -------------------------------------------------------------------------------- /profiler_gui/globals_qobjects.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : globals_qobjects.cpp 3 | * ----------------- : 4 | * creation time : 2016/08/08 5 | * authors : Victor Zarubkin, Sergey Yagovtsev 6 | * email : v.s.zarubkin@gmail.com, yse.sey@gmail.com 7 | * ----------------- : 8 | * description : The file contains implementation of GlobalSignals QObject class. 9 | * ----------------- : 10 | * change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.cpp 11 | * : 12 | * : * 13 | * ----------------- : 14 | * license : Lightweight profiler library for c++ 15 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 16 | * : 17 | * : Licensed under either of 18 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 19 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 20 | * : at your option. 21 | * : 22 | * : The MIT License 23 | * : 24 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 25 | * : of this software and associated documentation files (the "Software"), to deal 26 | * : in the Software without restriction, including without limitation the rights 27 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 28 | * : of the Software, and to permit persons to whom the Software is furnished 29 | * : to do so, subject to the following conditions: 30 | * : 31 | * : The above copyright notice and this permission notice shall be included in all 32 | * : copies or substantial portions of the Software. 33 | * : 34 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 35 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 36 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 37 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 38 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 39 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 40 | * : 41 | * : The Apache License, Version 2.0 (the "License") 42 | * : 43 | * : You may not use this file except in compliance with the License. 44 | * : You may obtain a copy of the License at 45 | * : 46 | * : http://www.apache.org/licenses/LICENSE-2.0 47 | * : 48 | * : Unless required by applicable law or agreed to in writing, software 49 | * : distributed under the License is distributed on an "AS IS" BASIS, 50 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 51 | * : See the License for the specific language governing permissions and 52 | * : limitations under the License. 53 | ************************************************************************/ 54 | 55 | #include "globals_qobjects.h" 56 | 57 | ////////////////////////////////////////////////////////////////////////// 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | namespace profiler_gui { 61 | 62 | GlobalSignals::GlobalSignals() : QObject() 63 | { 64 | } 65 | 66 | GlobalSignals::~GlobalSignals() 67 | { 68 | } 69 | 70 | } // END of namespace profiler_gui. 71 | 72 | ////////////////////////////////////////////////////////////////////////// 73 | -------------------------------------------------------------------------------- /profiler_gui/images/attribution.txt: -------------------------------------------------------------------------------- 1 | logo.svg - Icon made by Freepik from www.flaticon.com 2 | 3 | default/off.svg - Icon made by Freepik from www.flaticon.com 4 | default/open-folder.svg - Icon made by Freepik from www.flaticon.com 5 | default/open-folder2.svg - Icon made by Freepik from www.flaticon.com 6 | default/reload-folder2.svg - Icon made by Freepik from www.flaticon.com 7 | default/reload.svg - Icon made by Freepik from www.flaticon.com 8 | default/expand.svg - Icon made by Freepik from www.flaticon.com 9 | default/collapse.svg - Icon made by Freepik from www.flaticon.com 10 | default/colors.svg - Icon made by Freepik from www.flaticon.com 11 | default/colors-black.svg - Icon made by Freepik from www.flaticon.com 12 | default/save.svg - Icon made by Freepik from www.flaticon.com 13 | default/statistics.svg - Icon made by Freepik from www.flaticon.com 14 | default/statistics2.svg - Icon made by Freepik from www.flaticon.com 15 | default/lan.svg - Icon made by Freepik from www.flaticon.com 16 | default/lan_on.svg - Icon made by Freepik from www.flaticon.com 17 | default/wifi.svg - Icon made by Freepik from www.flaticon.com 18 | default/wifi_on.svg - Icon made by Freepik from www.flaticon.com 19 | default/play.svg - Icon made by Google from www.flaticon.com 20 | default/stop.svg - Icon made by Google from www.flaticon.com 21 | default/delete.svg - Icon made by Google from www.flaticon.com 22 | default/list.svg - Icon made by Freepik from www.flaticon.com 23 | default/search-prev.svg - Icon made by Freepik from www.flaticon.com 24 | default/search-next.svg - Icon made by Freepik from www.flaticon.com 25 | default/settings.svg - Icon made by Freepik from www.flaticon.com 26 | default/check.svg - Icon made by Kirill Kazachek from www.flaticon.com 27 | default/check-disabled.svg - Icon made by Kirill Kazachek from www.flaticon.com 28 | default/binoculars.svg - Icon made by Gregor Cresnar from www.flaticon.com 29 | default/close-white.svg - Icon made by Cole Bemis from www.flaticon.com 30 | default/close-white-hover.svg - Icon made by Cole Bemis from www.flaticon.com 31 | default/close-white-pressed.svg - Icon made by Cole Bemis from www.flaticon.com 32 | default/close.svg - Icon made by Freepik from www.flaticon.com 33 | default/close-hover.svg - Icon made by Freepik from www.flaticon.com 34 | default/maximize-white.svg - Icon made by Freepik from www.flaticon.com 35 | default/maximize-white-hover.svg - Icon made by Freepik from www.flaticon.com 36 | default/maximize-white-pressed.svg - Icon made by Freepik from www.flaticon.com 37 | default/minimize.svg - Icon made by Freepik from www.flaticon.com 38 | default/minimize-white.svg - Icon made by Freepik from www.flaticon.com 39 | default/minimize-white-pressed.svg - Icon made by Freepik from www.flaticon.com 40 | default/arrow-down.svg - Icon made by Freepik from www.flaticon.com 41 | default/arrow-down-hover.svg - Icon made by Freepik from www.flaticon.com 42 | default/arrow-down-pressed.svg - Icon made by Freepik from www.flaticon.com 43 | default/arrow-down-disabled.svg - Icon made by Freepik from www.flaticon.com 44 | default/arrow-up.svg - Icon made by Freepik from www.flaticon.com 45 | default/arrow-up-hover.svg - Icon made by Freepik from www.flaticon.com 46 | default/arrow-up-pressed.svg - Icon made by Freepik from www.flaticon.com 47 | default/arrow-up-disabled.svg - Icon made by Freepik from www.flaticon.com 48 | default/arrow-left.svg - Icon made by Freepik from www.flaticon.com 49 | default/arrow-right.svg - Icon made by Freepik from www.flaticon.com 50 | default/crop.svg - Icon made by Freepik from www.flaticon.com 51 | default/yx.svg - Icon made by Freepik from www.flaticon.com 52 | default/svg2.svg - Icon made by Freepik from www.flaticon.com 53 | default/svg3.svg - Icon made by Freepik from www.flaticon.com 54 | default/to-window.svg - Icon made by Freepik from www.flaticon.com 55 | default/window.svg - Icon made by Freepik from www.flaticon.com 56 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-down-disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-down-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-down-pressed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-down.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-left.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-right.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-up-disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-up-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-up-pressed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/arrow-up.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/big-o.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 15 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /profiler_gui/images/default/binoculars.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 10 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /profiler_gui/images/default/check-disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /profiler_gui/images/default/check-partial-disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /profiler_gui/images/default/check-partial.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /profiler_gui/images/default/check.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /profiler_gui/images/default/close-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/close-white-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/close-white-pressed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/close-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/collapse.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 11 | 13 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/colors-black.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /profiler_gui/images/default/colors.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 22 | 25 | 28 | 30 | 33 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /profiler_gui/images/default/crop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 10 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /profiler_gui/images/default/csv.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /profiler_gui/images/default/delete-old.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /profiler_gui/images/default/delete.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /profiler_gui/images/default/expand.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 12 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /profiler_gui/images/default/lan.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /profiler_gui/images/default/lan_on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /profiler_gui/images/default/list.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 11 | 13 | 15 | 18 | 20 | 22 | 24 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /profiler_gui/images/default/maximize-white-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/maximize-white-pressed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/maximize-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/minimize-white-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/minimize-white-pressed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/minimize-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/minimize.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /profiler_gui/images/default/off.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /profiler_gui/images/default/open-folder.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /profiler_gui/images/default/open-folder2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/play.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /profiler_gui/images/default/radio-indicator-disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /profiler_gui/images/default/radio-indicator.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /profiler_gui/images/default/reload-folder2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 10 | 14 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /profiler_gui/images/default/reload.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /profiler_gui/images/default/save.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | image/svg+xml -------------------------------------------------------------------------------- /profiler_gui/images/default/search-next.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 14 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /profiler_gui/images/default/search-prev.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 14 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /profiler_gui/images/default/settings.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 16 | 27 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /profiler_gui/images/default/statistics.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 11 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /profiler_gui/images/default/statistics2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 13 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/default/stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /profiler_gui/images/default/to-fullscreen.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /profiler_gui/images/default/to-window.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 13 | 14 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /profiler_gui/images/default/wifi.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 12 | 15 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /profiler_gui/images/default/wifi_on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 12 | 15 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /profiler_gui/images/default/window.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /profiler_gui/images/default/yx.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 12 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /profiler_gui/images/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yse/easy_profiler/3283b7c0d3c81a1caa358e11ec3da6207ff47112/profiler_gui/images/logo.ico -------------------------------------------------------------------------------- /profiler_gui/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 15 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /profiler_gui/main.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : main.cpp 3 | * ----------------- : 4 | * creation time : 2016/04/29 5 | * authors : Sergey Yagovtsev, Victor Zarubkin 6 | * email : yse.sey@gmail.com, v.s.zarubkin@gmail.com 7 | * ----------------- : 8 | * description : Main file for EasyProfiler GUI. 9 | * ----------------- : 10 | * license : Lightweight profiler library for c++ 11 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 12 | * : 13 | * : Licensed under either of 14 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 15 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 16 | * : at your option. 17 | * : 18 | * : The MIT License 19 | * : 20 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 21 | * : of this software and associated documentation files (the "Software"), to deal 22 | * : in the Software without restriction, including without limitation the rights 23 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 24 | * : of the Software, and to permit persons to whom the Software is furnished 25 | * : to do so, subject to the following conditions: 26 | * : 27 | * : The above copyright notice and this permission notice shall be included in all 28 | * : copies or substantial portions of the Software. 29 | * : 30 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 31 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 32 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 33 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 34 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 35 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | * : 37 | * : The Apache License, Version 2.0 (the "License") 38 | * : 39 | * : You may not use this file except in compliance with the License. 40 | * : You may obtain a copy of the License at 41 | * : 42 | * : http://www.apache.org/licenses/LICENSE-2.0 43 | * : 44 | * : Unless required by applicable law or agreed to in writing, software 45 | * : distributed under the License is distributed on an "AS IS" BASIS, 46 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 47 | * : See the License for the specific language governing permissions and 48 | * : limitations under the License. 49 | ************************************************************************/ 50 | 51 | #include 52 | #include 53 | #include "main_window.h" 54 | #include "globals.h" 55 | #include "thread_pool.h" 56 | 57 | #if defined(_WIN32) && defined (_BUILD_RELEASE_) 58 | #pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") 59 | #endif 60 | 61 | int main(int argc, char **argv) 62 | { 63 | auto now = ::std::chrono::duration_cast(::std::chrono::system_clock::now().time_since_epoch()).count() >> 1; 64 | srand((unsigned int)now); 65 | 66 | // Instanciate thread pool to avoid data races for compilers without C++11 thread-safe statics 67 | ThreadPool::instance(); 68 | 69 | QApplication app(argc, argv); 70 | 71 | // Instanciate easy globals after QApplication to allow creation of global fonts, and on the main thread to avoid data races 72 | profiler_gui::Globals::instance(); 73 | 74 | MainWindow window; 75 | window.show(); 76 | 77 | return app.exec(); 78 | } 79 | -------------------------------------------------------------------------------- /profiler_gui/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | themes/default.css 4 | 5 | 6 | images/logo.svg 7 | 8 | 9 | images/default/binoculars.svg 10 | images/default/close.svg 11 | images/default/close-hover.svg 12 | images/default/crop.svg 13 | images/default/off.svg 14 | images/default/open-folder2.svg 15 | images/default/reload.svg 16 | images/default/expand.svg 17 | images/default/collapse.svg 18 | images/default/to-fullscreen.svg 19 | images/default/to-window.svg 20 | images/default/minimize.svg 21 | images/default/save.svg 22 | images/default/statistics.svg 23 | images/default/statistics2.svg 24 | images/default/lan.svg 25 | images/default/lan_on.svg 26 | images/default/wifi.svg 27 | images/default/wifi_on.svg 28 | images/default/lan.svg 29 | images/default/lan_on.svg 30 | images/default/play.svg 31 | images/default/stop.svg 32 | images/default/delete.svg 33 | images/default/list.svg 34 | images/default/search-next.svg 35 | images/default/search-prev.svg 36 | images/default/settings.svg 37 | images/default/check.svg 38 | images/default/check-disabled.svg 39 | images/default/radio-indicator.svg 40 | images/default/radio-indicator-disabled.svg 41 | images/default/check-partial.svg 42 | images/default/check-partial-disabled.svg 43 | images/default/maximize-white.svg 44 | images/default/maximize-white-hover.svg 45 | images/default/maximize-white-pressed.svg 46 | images/default/minimize-white.svg 47 | images/default/minimize-white-hover.svg 48 | images/default/minimize-white-pressed.svg 49 | images/default/close-white.svg 50 | images/default/close-white-hover.svg 51 | images/default/close-white-pressed.svg 52 | images/default/arrow-up.svg 53 | images/default/arrow-up-hover.svg 54 | images/default/arrow-up-pressed.svg 55 | images/default/arrow-up-disabled.svg 56 | images/default/arrow-down.svg 57 | images/default/arrow-down-hover.svg 58 | images/default/arrow-down-pressed.svg 59 | images/default/arrow-down-disabled.svg 60 | images/default/arrow-right.svg 61 | images/default/yx.svg 62 | images/default/big-o.svg 63 | images/default/csv.svg 64 | images/default/window.svg 65 | 66 | 67 | -------------------------------------------------------------------------------- /profiler_gui/resources.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "images/logo.ico" 2 | 1 VERSIONINFO 3 | FILEVERSION EASY_PROFILER_VERSION_MAJOR, EASY_PROFILER_VERSION_MINOR, EASY_PROFILER_VERSION_PATCH 4 | PRODUCTVERSION EASY_PROFILER_VERSION_MAJOR, EASY_PROFILER_VERSION_MINOR, EASY_PROFILER_VERSION_PATCH 5 | 6 | # define EASY_STRINGIFY(a) #a 7 | # define EASY_STRINGIFICATION(a) EASY_STRINGIFY(a) 8 | 9 | #define EASY_PROFILER_PRODUCT_VERSION "v" EASY_STRINGIFICATION(EASY_PROFILER_VERSION_MAJOR) "." \ 10 | EASY_STRINGIFICATION(EASY_PROFILER_VERSION_MINOR) "." \ 11 | EASY_STRINGIFICATION(EASY_PROFILER_VERSION_PATCH) 12 | 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "080904b0" 17 | BEGIN 18 | VALUE "CompanyName", "EasySolutions" 19 | VALUE "FileDescription", "EasyProfiler" 20 | VALUE "InternalName", "profiler_gui" 21 | VALUE "LegalCopyright", "Copyright (C) 2016-2019 Victor Zarubkin, Sergey Yagovtsev" 22 | VALUE "LegalTrademarks1", "All Rights Reserved" 23 | VALUE "LegalTrademarks2", "All Rights Reserved" 24 | VALUE "OriginalFilename", "profiler_gui.exe" 25 | VALUE "ProductName", "easy_profiler gui application" 26 | VALUE "ProductVersion", EASY_PROFILER_PRODUCT_VERSION 27 | END 28 | END 29 | BLOCK "VarFileInfo" 30 | BEGIN 31 | VALUE "Translation", 0x809, 1200 32 | END 33 | END 34 | -------------------------------------------------------------------------------- /profiler_gui/socket_listener.h: -------------------------------------------------------------------------------- 1 | /** 2 | Lightweight profiler library for c++ 3 | Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 4 | 5 | Licensed under either of 6 | * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 7 | * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 8 | at your option. 9 | 10 | The MIT License 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished 16 | to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | 29 | The Apache License, Version 2.0 (the "License"); 30 | You may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | **/ 42 | 43 | #ifndef EASY_PROFILER_SOCKET_LISTENER_H 44 | #define EASY_PROFILER_SOCKET_LISTENER_H 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #include 52 | 53 | #include 54 | 55 | namespace profiler { namespace net { struct EasyProfilerStatus; } } 56 | 57 | ////////////////////////////////////////////////////////////////////////// 58 | 59 | enum class ListenerRegime : uint8_t 60 | { 61 | Idle = 0, 62 | Capture, 63 | Capture_Receive, 64 | Descriptors 65 | }; 66 | 67 | class SocketListener Q_DECL_FINAL 68 | { 69 | EasySocket m_easySocket; ///< 70 | std::string m_address; ///< 71 | std::stringstream m_receivedData; ///< 72 | std::thread m_thread; ///< 73 | uint64_t m_receivedSize; ///< 74 | uint16_t m_port; ///< 75 | std::atomic m_frameMax; ///< 76 | std::atomic m_frameAvg; ///< 77 | std::atomic_bool m_bInterrupt; ///< 78 | std::atomic_bool m_bConnected; ///< 79 | std::atomic_bool m_bStopReceive; ///< 80 | std::atomic_bool m_bCaptureReady; ///< 81 | std::atomic_bool m_bFrameTimeReady; ///< 82 | ListenerRegime m_regime; ///< 83 | 84 | public: 85 | 86 | SocketListener(); 87 | ~SocketListener(); 88 | 89 | bool connected() const; 90 | bool captured() const; 91 | ListenerRegime regime() const; 92 | uint64_t size() const; 93 | const std::string& address() const; 94 | uint16_t port() const; 95 | 96 | std::stringstream& data(); 97 | void clearData(); 98 | 99 | void disconnect(); 100 | void closeSocket(); 101 | bool connect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply, bool _disconnectFirst = false); 102 | bool reconnect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply); 103 | 104 | bool startCapture(); 105 | void stopCapture(); 106 | void finalizeCapture(); 107 | void requestBlocksDescription(); 108 | 109 | bool frameTime(uint32_t& _maxTime, uint32_t& _avgTime); 110 | bool requestFrameTime(); 111 | 112 | template 113 | void send(const T& _message) { 114 | m_easySocket.send(&_message, sizeof(T)); 115 | } 116 | 117 | private: 118 | 119 | void listenCapture(); 120 | void listenDescription(); 121 | void listenFrameTime(); 122 | 123 | }; // END of class SocketListener. 124 | 125 | #endif //EASY_PROFILER_SOCKET_LISTENER_H 126 | -------------------------------------------------------------------------------- /profiler_gui/text_highlighter.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : text_highlighter.cpp 3 | * ----------------- : 4 | * creation time : 2019/10/12 5 | * author : Victor Zarubkin 6 | * email : v.s.zarubkin@gmail.com 7 | * ----------------- : 8 | * description : The file contains implementation of TextHighlighter. 9 | * ----------------- : 10 | * license : Lightweight profiler library for c++ 11 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 12 | * : 13 | * : Licensed under either of 14 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 15 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 16 | * : at your option. 17 | * : 18 | * : The MIT License 19 | * : 20 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 21 | * : of this software and associated documentation files (the "Software"), to deal 22 | * : in the Software without restriction, including without limitation the rights 23 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 24 | * : of the Software, and to permit persons to whom the Software is furnished 25 | * : to do so, subject to the following conditions: 26 | * : 27 | * : The above copyright notice and this permission notice shall be included in all 28 | * : copies or substantial portions of the Software. 29 | * : 30 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 31 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 32 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 33 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 34 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 35 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | * : 37 | * : The Apache License, Version 2.0 (the "License") 38 | * : 39 | * : You may not use this file except in compliance with the License. 40 | * : You may obtain a copy of the License at 41 | * : 42 | * : http://www.apache.org/licenses/LICENSE-2.0 43 | * : 44 | * : Unless required by applicable law or agreed to in writing, software 45 | * : distributed under the License is distributed on an "AS IS" BASIS, 46 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 47 | * : See the License for the specific language governing permissions and 48 | * : limitations under the License. 49 | ************************************************************************/ 50 | 51 | #include "text_highlighter.h" 52 | #include 53 | #include 54 | 55 | #include 56 | #include "common_functions.h" 57 | 58 | EASY_CONSTEXPR auto HighlightColor = profiler::colors::Yellow; 59 | EASY_CONSTEXPR auto CurrentHighlightColor = profiler::colors::Magenta; 60 | 61 | TextHighlighter::TextHighlighter( 62 | QTextDocument* doc, 63 | const QColor& normalTextColor, 64 | const QColor& lightTextColor, 65 | const QString& pattern, 66 | Qt::CaseSensitivity caseSensitivity, 67 | bool current 68 | ) 69 | : QSyntaxHighlighter(doc) 70 | , m_pattern(pattern) 71 | , m_caseSensitivity(caseSensitivity) 72 | { 73 | auto color = current ? CurrentHighlightColor : HighlightColor; 74 | m_textCharFormat.setBackground(QColor::fromRgba(color)); 75 | m_textCharFormat.setForeground(profiler_gui::isLightColor(color) ? normalTextColor : lightTextColor); 76 | } 77 | 78 | TextHighlighter::~TextHighlighter() 79 | { 80 | 81 | } 82 | 83 | void TextHighlighter::highlightBlock(const QString& text) 84 | { 85 | if (m_pattern.isEmpty()) 86 | { 87 | return; 88 | } 89 | 90 | QRegExp expression(m_pattern, m_caseSensitivity); 91 | int index = text.indexOf(expression.pattern()); 92 | while (index >= 0) 93 | { 94 | const auto length = expression.cap().length(); 95 | setFormat(index, length, m_textCharFormat); 96 | 97 | auto prevIndex = index; 98 | index = text.indexOf(expression.pattern(), index + length); 99 | if (index <= prevIndex) 100 | { 101 | break; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /profiler_gui/text_highlighter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : text_highlighter.h 3 | * ----------------- : 4 | * creation time : 2019/10/12 5 | * author : Victor Zarubkin 6 | * email : v.s.zarubkin@gmail.com 7 | * ----------------- : 8 | * description : The file contains declaration of TextHighlighter - an auxiliary class 9 | * : for highlighting text in QTextDocument. 10 | * ----------------- : 11 | * license : Lightweight profiler library for c++ 12 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 13 | * : 14 | * : Licensed under either of 15 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 16 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 17 | * : at your option. 18 | * : 19 | * : The MIT License 20 | * : 21 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 22 | * : of this software and associated documentation files (the "Software"), to deal 23 | * : in the Software without restriction, including without limitation the rights 24 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 25 | * : of the Software, and to permit persons to whom the Software is furnished 26 | * : to do so, subject to the following conditions: 27 | * : 28 | * : The above copyright notice and this permission notice shall be included in all 29 | * : copies or substantial portions of the Software. 30 | * : 31 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 32 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 33 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 34 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 35 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 36 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | * : 38 | * : The Apache License, Version 2.0 (the "License") 39 | * : 40 | * : You may not use this file except in compliance with the License. 41 | * : You may obtain a copy of the License at 42 | * : 43 | * : http://www.apache.org/licenses/LICENSE-2.0 44 | * : 45 | * : Unless required by applicable law or agreed to in writing, software 46 | * : distributed under the License is distributed on an "AS IS" BASIS, 47 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 48 | * : See the License for the specific language governing permissions and 49 | * : limitations under the License. 50 | ************************************************************************/ 51 | 52 | #ifndef EASY_PROFILER_TEXT_HIGHLIGHTER_H 53 | #define EASY_PROFILER_TEXT_HIGHLIGHTER_H 54 | 55 | #include 56 | 57 | class TextHighlighter : public QSyntaxHighlighter 58 | { 59 | Q_OBJECT 60 | 61 | QString m_pattern; 62 | Qt::CaseSensitivity m_caseSensitivity; 63 | QTextCharFormat m_textCharFormat; 64 | 65 | public: 66 | 67 | TextHighlighter( 68 | QTextDocument* doc, 69 | const QColor& normalTextColor, 70 | const QColor& lightTextColor, 71 | const QString& pattern, 72 | Qt::CaseSensitivity caseSensitivity, 73 | bool current 74 | ); 75 | 76 | ~TextHighlighter() override; 77 | 78 | protected: 79 | 80 | void highlightBlock(const QString& text) override; 81 | }; 82 | 83 | #endif //EASY_PROFILER_TEXT_HIGHLIGHTER_H 84 | -------------------------------------------------------------------------------- /profiler_gui/thread_pool_task.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : thread_pool_task.h 3 | * ----------------- : 4 | * creation time : 2018/01/28 5 | * author : Victor Zarubkin 6 | * email : v.s.zarubkin@gmail.com 7 | * ----------------- : 8 | * description : The file contains declaration of ThreadPoolTask. 9 | * ----------------- : 10 | * license : Lightweight profiler library for c++ 11 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 12 | * : 13 | * : Licensed under either of 14 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 15 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 16 | * : at your option. 17 | * : 18 | * : The MIT License 19 | * : 20 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 21 | * : of this software and associated documentation files (the "Software"), to deal 22 | * : in the Software without restriction, including without limitation the rights 23 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 24 | * : of the Software, and to permit persons to whom the Software is furnished 25 | * : to do so, subject to the following conditions: 26 | * : 27 | * : The above copyright notice and this permission notice shall be included in all 28 | * : copies or substantial portions of the Software. 29 | * : 30 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 31 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 32 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 33 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 34 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 35 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | * : 37 | * : The Apache License, Version 2.0 (the "License") 38 | * : 39 | * : You may not use this file except in compliance with the License. 40 | * : You may obtain a copy of the License at 41 | * : 42 | * : http://www.apache.org/licenses/LICENSE-2.0 43 | * : 44 | * : Unless required by applicable law or agreed to in writing, software 45 | * : distributed under the License is distributed on an "AS IS" BASIS, 46 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 47 | * : See the License for the specific language governing permissions and 48 | * : limitations under the License. 49 | ************************************************************************/ 50 | 51 | #ifndef EASY_PROFILER_THREAD_POOL_TASK_H 52 | #define EASY_PROFILER_THREAD_POOL_TASK_H 53 | 54 | #include 55 | #include 56 | #include 57 | #include 58 | 59 | #include 60 | 61 | enum class TaskStatus : int8_t 62 | { 63 | Enqueued, 64 | Processing, 65 | Finished, 66 | }; 67 | 68 | class ThreadPoolTaskSignals : public QObject 69 | { 70 | Q_OBJECT; 71 | 72 | public: 73 | 74 | ThreadPoolTaskSignals() : QObject() {} 75 | 76 | signals: 77 | 78 | void finished(); 79 | }; 80 | 81 | class ThreadPoolTask EASY_FINAL 82 | { 83 | public: 84 | 85 | using Func = std::function; 86 | 87 | private: 88 | 89 | friend class ThreadPool; 90 | 91 | ThreadPoolTaskSignals m_signals; 92 | Func m_func; 93 | std::atomic_bool* m_interrupt; 94 | std::mutex m_mutex; 95 | std::atomic m_status; 96 | const bool m_creatingQtObjects; 97 | 98 | public: 99 | 100 | ThreadPoolTask(const ThreadPoolTask&) = delete; 101 | ThreadPoolTask(ThreadPoolTask&&) = delete; 102 | 103 | explicit ThreadPoolTask(bool creatingQtObjects = false); 104 | ~ThreadPoolTask(); 105 | 106 | void enqueue(Func&& func, std::atomic_bool& interruptFlag); 107 | void dequeue(); 108 | 109 | ThreadPoolTaskSignals& events(); 110 | 111 | private: 112 | 113 | bool creatingQtObjects() const; 114 | 115 | void operator() (); 116 | 117 | TaskStatus status() const; 118 | void setStatus(TaskStatus status); 119 | }; 120 | 121 | #endif //EASY_PROFILER_THREAD_POOL_TASK_H 122 | -------------------------------------------------------------------------------- /profiler_gui/timer.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : timer.cpp 3 | * ----------------- : 4 | * creation time : 2016/12/05 5 | * author : Victor Zarubkin 6 | * email : v.s.zarubkin@gmail.com 7 | * ----------------- : 8 | * description : This file contains implementation of Timer class used to 9 | * : connect QTimer to non-QObject classes. 10 | * ----------------- : 11 | * change log : * 2016/12/05 Victor Zarubkin: Initial commit. 12 | * : 13 | * : * 14 | * ----------------- : 15 | * license : Lightweight profiler library for c++ 16 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 17 | * : 18 | * : Licensed under either of 19 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 20 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 21 | * : at your option. 22 | * : 23 | * : The MIT License 24 | * : 25 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 26 | * : of this software and associated documentation files (the "Software"), to deal 27 | * : in the Software without restriction, including without limitation the rights 28 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 29 | * : of the Software, and to permit persons to whom the Software is furnished 30 | * : to do so, subject to the following conditions: 31 | * : 32 | * : The above copyright notice and this permission notice shall be included in all 33 | * : copies or substantial portions of the Software. 34 | * : 35 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 36 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 37 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 38 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 39 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 40 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 41 | * : 42 | * : The Apache License, Version 2.0 (the "License") 43 | * : 44 | * : You may not use this file except in compliance with the License. 45 | * : You may obtain a copy of the License at 46 | * : 47 | * : http://www.apache.org/licenses/LICENSE-2.0 48 | * : 49 | * : Unless required by applicable law or agreed to in writing, software 50 | * : distributed under the License is distributed on an "AS IS" BASIS, 51 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 52 | * : See the License for the specific language governing permissions and 53 | * : limitations under the License. 54 | ************************************************************************/ 55 | 56 | #include "timer.h" 57 | 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | Timer::Timer() 61 | : QObject() 62 | { 63 | connect(&m_timer, &QTimer::timeout, this, &Timer::onTimeout); 64 | } 65 | 66 | Timer::Timer(std::function&& handler, bool signleShot) 67 | : QObject() 68 | , m_handler(std::forward&&>(handler)) 69 | { 70 | m_timer.setSingleShot(signleShot); 71 | connect(&m_timer, &QTimer::timeout, this, &Timer::onTimeout); 72 | } 73 | 74 | Timer::~Timer() 75 | { 76 | 77 | } 78 | 79 | void Timer::onTimeout() 80 | { 81 | m_handler(); 82 | } 83 | 84 | void Timer::setHandler(std::function&& handler) 85 | { 86 | m_handler = handler; 87 | } 88 | 89 | void Timer::setSignleShot(bool singleShot) 90 | { 91 | m_timer.setSingleShot(singleShot); 92 | } 93 | 94 | bool Timer::isSingleShot() const 95 | { 96 | return m_timer.isSingleShot(); 97 | } 98 | 99 | void Timer::setInterval(int msec) 100 | { 101 | m_timer.setInterval(msec); 102 | } 103 | 104 | void Timer::start(int msec) 105 | { 106 | stop(); 107 | m_timer.start(msec); 108 | } 109 | 110 | void Timer::start() 111 | { 112 | stop(); 113 | m_timer.start(); 114 | } 115 | 116 | void Timer::stop() 117 | { 118 | if (m_timer.isActive()) 119 | m_timer.stop(); 120 | } 121 | 122 | bool Timer::isActive() const 123 | { 124 | return m_timer.isActive(); 125 | } 126 | 127 | ////////////////////////////////////////////////////////////////////////// 128 | 129 | -------------------------------------------------------------------------------- /profiler_gui/timer.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * file name : timer.h 3 | * ----------------- : 4 | * creation time : 2016/12/05 5 | * author : Victor Zarubkin 6 | * email : v.s.zarubkin@gmail.com 7 | * ----------------- : 8 | * description : This file contains declaration of Timer class used to 9 | * : connect QTimer to non-QObject classes. 10 | * ----------------- : 11 | * change log : * 2016/12/05 Victor Zarubkin: Initial commit. 12 | * : 13 | * : * 14 | * ----------------- : 15 | * license : Lightweight profiler library for c++ 16 | * : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin 17 | * : 18 | * : Licensed under either of 19 | * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT) 20 | * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0) 21 | * : at your option. 22 | * : 23 | * : The MIT License 24 | * : 25 | * : Permission is hereby granted, free of charge, to any person obtaining a copy 26 | * : of this software and associated documentation files (the "Software"), to deal 27 | * : in the Software without restriction, including without limitation the rights 28 | * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 29 | * : of the Software, and to permit persons to whom the Software is furnished 30 | * : to do so, subject to the following conditions: 31 | * : 32 | * : The above copyright notice and this permission notice shall be included in all 33 | * : copies or substantial portions of the Software. 34 | * : 35 | * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 36 | * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 37 | * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 38 | * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 39 | * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 40 | * : USE OR OTHER DEALINGS IN THE SOFTWARE. 41 | * : 42 | * : The Apache License, Version 2.0 (the "License") 43 | * : 44 | * : You may not use this file except in compliance with the License. 45 | * : You may obtain a copy of the License at 46 | * : 47 | * : http://www.apache.org/licenses/LICENSE-2.0 48 | * : 49 | * : Unless required by applicable law or agreed to in writing, software 50 | * : distributed under the License is distributed on an "AS IS" BASIS, 51 | * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 52 | * : See the License for the specific language governing permissions and 53 | * : limitations under the License. 54 | ************************************************************************/ 55 | 56 | #ifndef TIMER_H 57 | #define TIMER_H 58 | 59 | #include 60 | #include 61 | 62 | ////////////////////////////////////////////////////////////////////////// 63 | 64 | class Timer : public QObject 65 | { 66 | Q_OBJECT 67 | 68 | private: 69 | 70 | QTimer m_timer; 71 | ::std::function m_handler; 72 | 73 | public: 74 | 75 | explicit Timer(); 76 | explicit Timer(std::function&& handler, bool signleShot = false); 77 | ~Timer() override; 78 | 79 | void setHandler(std::function&& handler); 80 | 81 | void setSignleShot(bool singleShot); 82 | bool isSingleShot() const; 83 | 84 | void setInterval(int msec); 85 | void start(int msec); 86 | void start(); 87 | void stop(); 88 | bool isActive() const; 89 | 90 | private slots: 91 | 92 | void onTimeout(); 93 | 94 | }; // END of class Timer. 95 | 96 | ////////////////////////////////////////////////////////////////////////// 97 | 98 | #endif // TIMER_H 99 | -------------------------------------------------------------------------------- /reader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable(profiler_reader main.cpp) 3 | target_link_libraries(profiler_reader easy_profiler) 4 | -------------------------------------------------------------------------------- /reader/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | class TreePrinter 18 | { 19 | struct Info{ 20 | std::string name; 21 | std::string info; 22 | }; 23 | std::vector m_rows; 24 | 25 | public: 26 | TreePrinter(){ 27 | 28 | } 29 | void addNewRow(int level) 30 | { 31 | 32 | } 33 | 34 | void printTree() 35 | { 36 | for (auto& row : m_rows){ 37 | std::cout << row.name << " " << row.info << std::endl; 38 | } 39 | } 40 | }; 41 | 42 | 43 | void printTree(TreePrinter& printer, const profiler::BlocksTree& tree, int level = 0, profiler::timestamp_t parent_dur = 0, profiler::timestamp_t root_dur = 0) 44 | { 45 | // 46 | //if (tree.node){ 47 | // auto duration = tree.node->block()->duration(); 48 | // float duration_ms = duration / 1e6f; 49 | // float percent = parent_dur ? float(duration) / float(parent_dur)*100.0f : 100.0f; 50 | // float rpercent = root_dur ? float(duration) / float(root_dur)*100.0f : 100.0f; 51 | // std::cout << std::string(level, '\t') << tree.node->getName() 52 | // << std::string(5 - level, '\t') 53 | // /*<< std::string(level, ' ')*/ << percent << "%| " 54 | // << rpercent << "%| " 55 | // << duration_ms << " ms" 56 | // << std::endl; 57 | // if (root_dur == 0){ 58 | // root_dur = tree.node->block()->duration(); 59 | // } 60 | //} 61 | //else{ 62 | // root_dur = 0; 63 | //} 64 | // 65 | 66 | //for (const auto& i : tree.children){ 67 | 68 | // printTree(printer, i, level + 1, tree.node ? tree.node->block()->duration() : 0, root_dur); 69 | //} 70 | } 71 | 72 | int main(int argc, char* argv[]) 73 | { 74 | 75 | profiler::thread_blocks_tree_t threaded_trees; 76 | 77 | ::std::string filename;// = "test.prof"; 78 | if (argc > 1 && argv[1]) 79 | { 80 | filename = argv[1]; 81 | } 82 | else 83 | { 84 | std::cout << "Specify prof file: "; 85 | std::getline(std::cin, filename); 86 | //return 255; 87 | } 88 | 89 | ::std::string dump_filename; 90 | if (argc > 2 && argv[2]) 91 | { 92 | dump_filename = argv[2]; 93 | } 94 | else 95 | { 96 | std::cout << "Specify output prof file: "; 97 | std::getline(std::cin, dump_filename); 98 | } 99 | 100 | if (dump_filename.size() > 2) 101 | { 102 | EASY_PROFILER_ENABLE; 103 | std::cout << "Will dump reader prof file to " << dump_filename << std::endl; 104 | } 105 | else 106 | { 107 | dump_filename.clear(); 108 | } 109 | 110 | 111 | auto start = std::chrono::system_clock::now(); 112 | 113 | profiler::SerializedData serialized_blocks, serialized_descriptors; 114 | profiler::descriptors_list_t descriptors; 115 | profiler::blocks_t blocks; 116 | profiler::bookmarks_t bookmarks; 117 | profiler::BeginEndTime beginEndTime; 118 | std::stringstream errorMessage; 119 | uint32_t descriptorsNumberInFile = 0; 120 | uint32_t version = 0; 121 | profiler::processid_t pid = 0; 122 | 123 | auto blocks_counter = fillTreesFromFile(filename.c_str(), beginEndTime, serialized_blocks, serialized_descriptors, 124 | descriptors, blocks, threaded_trees, bookmarks, descriptorsNumberInFile, 125 | version, pid, true, errorMessage); 126 | if (blocks_counter == 0) 127 | std::cout << "Can not read blocks from file " << filename.c_str() << "\nReason: " << errorMessage.str(); 128 | 129 | auto end = std::chrono::system_clock::now(); 130 | 131 | std::cout << "Blocks count: " << blocks_counter << std::endl; 132 | std::cout << "dT = " << std::chrono::duration_cast(end - start).count() << " usec" << std::endl; 133 | //for (const auto & i : threaded_trees){ 134 | // TreePrinter p; 135 | // std::cout << std::string(20, '=') << " thread "<< i.first << " "<< std::string(20, '=') << std::endl; 136 | // printTree(p, i.second.tree,-1); 137 | //} 138 | 139 | if (!dump_filename.empty()) 140 | { 141 | auto bcount = profiler::dumpBlocksToFile(dump_filename.c_str()); 142 | 143 | std::cout << "Blocks count for reader: " << bcount << std::endl; 144 | } 145 | 146 | //char c; 147 | //::std::cin >> c; 148 | 149 | 150 | return 0; 151 | } 152 | -------------------------------------------------------------------------------- /sample/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "easy_profiler_sample", 3 | srcs = ["main.cpp"], 4 | deps = [ 5 | "//easy_profiler_core:easy_profiler", 6 | ], 7 | ) -------------------------------------------------------------------------------- /sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CPP_FILES 2 | main.cpp 3 | ) 4 | 5 | set(SOURCES 6 | ${CPP_FILES} 7 | ) 8 | 9 | link_directories(${CMAKE_SOURCE_DIR}/../bin) 10 | 11 | add_executable(profiler_sample ${SOURCES}) 12 | target_link_libraries(profiler_sample easy_profiler) 13 | 14 | add_executable(profiler_sample_disabled_profiler ${SOURCES}) 15 | target_link_libraries(profiler_sample_disabled_profiler easy_profiler) 16 | target_compile_definitions(profiler_sample_disabled_profiler PRIVATE DISABLE_EASY_PROFILER) 17 | -------------------------------------------------------------------------------- /sample/build_express_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TEMP_FILE_ENABLE="enable.info" 3 | TEMP_FILE_DISABLE="disable.info" 4 | OBJECTS="1000" 5 | 6 | $CXX_COMPILER -O3 -std=c++11 -I../easy_profiler_core/include/ -L../bin/ -leasy_profiler express_sample.cpp -o express_test_disabled 7 | $CXX_COMPILER -O3 -std=c++11 -I../easy_profiler_core/include/ -L../bin/ -leasy_profiler -DBUILD_WITH_EASY_PROFILER express_sample.cpp -o express_test_enabled 8 | 9 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../bin 10 | 11 | ./express_test_disabled $OBJECTS > $TEMP_FILE_DISABLE 12 | ./express_test_enabled $OBJECTS > $TEMP_FILE_ENABLE 13 | 14 | DT_ENA=`cat $TEMP_FILE_ENABLE | grep Elapsed| awk '{print $3}'` 15 | N_ENA=`cat $TEMP_FILE_ENABLE | grep Blocks| awk '{print $3}'` 16 | DT_DIS=`cat $TEMP_FILE_DISABLE | grep Elapsed| awk '{print $3}'` 17 | 18 | DELTA=$(($DT_ENA-$DT_DIS)) 19 | USEC_BLOCK=`awk "BEGIN{print $DELTA/$N_ENA}"` 20 | 21 | echo "~" $USEC_BLOCK "usec/block" 22 | -------------------------------------------------------------------------------- /sample/express_sample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | int OBJECTS = 500; 13 | 14 | void modellingThread(){ 15 | EASY_THREAD("Modelling"); 16 | 17 | static const int N = OBJECTS; 18 | 19 | volatile double *pos[N]; 20 | for (int i = 0; i < N; ++i) 21 | { 22 | pos[i] = new volatile double[3]; 23 | } 24 | 25 | { 26 | EASY_BLOCK("Collisions"); 27 | volatile int i, j; 28 | volatile double dist; 29 | for (i = 0; i < N; ++i) 30 | { 31 | for (j = i + 1; j < N; ++j) 32 | { 33 | EASY_BLOCK("Check"); 34 | volatile double v[3]; 35 | v[0] = pos[i][0] - pos[j][0]; 36 | v[1] = pos[i][1] - pos[j][1]; 37 | v[2] = pos[i][2] - pos[j][2]; 38 | dist = v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; 39 | if (dist < 10000) 40 | { 41 | dist *= dist; 42 | } 43 | } 44 | } 45 | } 46 | 47 | for (int i = 0; i < N; ++i) 48 | { 49 | delete [] pos[i]; 50 | } 51 | } 52 | 53 | ////////////////////////////////////////////////////////////////////////// 54 | 55 | int main(int argc, char* argv[]) 56 | { 57 | if (argc > 1 && argv[1]){ 58 | OBJECTS = std::atoi(argv[1]); 59 | } 60 | 61 | std::cout << "Objects count: " << OBJECTS << std::endl; 62 | 63 | auto start = std::chrono::system_clock::now(); 64 | 65 | 66 | EASY_PROFILER_ENABLE; 67 | EASY_MAIN_THREAD; 68 | 69 | 70 | modellingThread(); 71 | 72 | auto end = std::chrono::system_clock::now(); 73 | auto elapsed = 74 | std::chrono::duration_cast(end - start); 75 | 76 | std::cout << "Elapsed time: " << elapsed.count() << " usec" << std::endl; 77 | 78 | auto blocks_count = profiler::dumpBlocksToFile("test.prof"); 79 | 80 | std::cout << "Blocks count: " << blocks_count << std::endl; 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /scripts/context_switch_logger.stp: -------------------------------------------------------------------------------- 1 | global target_pid 2 | global target_name 3 | 4 | probe scheduler.ctxswitch { 5 | 6 | if (target_pid != 0 7 | && next_pid != target_pid 8 | && prev_pid != target_pid) 9 | next 10 | 11 | if (target_name != "" 12 | && prev_task_name != target_name 13 | && next_task_name != target_name) 14 | next 15 | 16 | //printf("Switch from %d(%s) to %d(%s) at %d\n",prev_tid, prev_task_name,next_tid,next_task_name, gettimeofday_ns()) 17 | printf("%d %d %d %s %d\n", get_cycles(), prev_tid, next_tid, next_task_name, next_pid) 18 | //printf("%d %d %d\n",gettimeofday_ns(),prev_tid, next_tid ) 19 | } 20 | 21 | probe begin 22 | { 23 | target_pid = 0 24 | target_name = "" 25 | 26 | %( $# == 1 || $# > 2 %? 27 | log("Wrong number of arguments, use none, 'pid nr' or 'name proc'") 28 | exit() 29 | %) 30 | 31 | %( $# == 2 %? 32 | if(@1 == "pid") 33 | target_pid = strtol(@2, 10) 34 | if(@1 == "name") 35 | target_name = @2 36 | %) 37 | } 38 | -------------------------------------------------------------------------------- /scripts/make_style.sh: -------------------------------------------------------------------------------- 1 | if [ "$#" -ne 1 ]; then 2 | echo -e "Usage: \n$0 DIRECTORY\n\twhere DIRECTORY is a directory with sources for styling" 3 | exit 1 4 | fi 5 | 6 | if ! [ -x "$(command -v clang-format)" ]; then 7 | echo 'Error: clang-format is not installed. Please install clang-format with minimal version 3.8' >&2 8 | exit 1 9 | fi 10 | 11 | DIR=$1 12 | 13 | FILES=`find $DIR -name "*.h" -or -name "*.cpp"` 14 | 15 | for FILE in $FILES 16 | do 17 | echo "Set style for $FILE" 18 | clang-format -i $FILE 19 | done 20 | -------------------------------------------------------------------------------- /scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | unamestr=`uname` 4 | SUBDIR="./bin" 5 | if [[ ! "$unamestr" == 'Linux' ]]; then 6 | SUBDIR="./bin/Release/" 7 | fi 8 | 9 | DISABLED_PROF=$SUBDIR/profiler_sample_disabled_profiler 10 | ENABLED_PROF=$SUBDIR/profiler_sample 11 | 12 | TEMP_FILE_ENABLE="enable.info" 13 | TEMP_FILE_DISABLE="disable.info" 14 | RESULT_FILE="result.csv" 15 | RESULT_FILE_TMP="result.csv.tmp" 16 | 17 | HEADER="Blocks count, dT prof enabled usec, dT prof disabled usec,delta, usec/block" 18 | 19 | #echo "Blocks count, dT prof enabled usec, dT prof disabled usec,delta, usec/block" > $RESULT_FILE 20 | 21 | rm -rf $RESULT_FILE 22 | 23 | for i in {1..9} 24 | do 25 | OBJECTS_COUNT=$(($i*100)) 26 | for j in {10..15} 27 | do 28 | RENDER_COUNT=$(($j*100)) 29 | for k in {10..15} 30 | do 31 | MODELLING_COUNT=$(($k*100)) 32 | $ENABLED_PROF $OBJECTS_COUNT $RENDER_COUNT $MODELLING_COUNT > $TEMP_FILE_ENABLE 33 | $DISABLED_PROF $OBJECTS_COUNT $RENDER_COUNT $MODELLING_COUNT > $TEMP_FILE_DISABLE 34 | DT_ENA=`cat $TEMP_FILE_ENABLE | grep Elapsed| awk '{print $3}'` 35 | N_ENA=`cat $TEMP_FILE_ENABLE | grep Blocks| awk '{print $3}'` 36 | N_DIS=`cat $TEMP_FILE_DISABLE | grep Elapsed| awk '{print $3}'` 37 | 38 | DELTA=$(($DT_ENA-$N_DIS)) 39 | USEC_BLOCK=`awk "BEGIN{print $DELTA/$N_ENA}"` 40 | 41 | echo $N_ENA,$DT_ENA,$N_DIS,$DELTA,$USEC_BLOCK >> $RESULT_FILE 42 | done 43 | done 44 | echo $i 45 | 46 | done 47 | 48 | cat $RESULT_FILE | sort > $RESULT_FILE_TMP 49 | 50 | echo $HEADER > $RESULT_FILE 51 | cat $RESULT_FILE_TMP >> $RESULT_FILE 52 | 53 | rm -rf $TEMP_FILE_ENABLE 54 | rm -rf $TEMP_FILE_DISABLE 55 | rm -rf $RESULT_FILE_TMP 56 | 57 | echo "See result in $RESULT_FILE" 58 | --------------------------------------------------------------------------------