Skip to content

Commit

Permalink
Merge tag 'v2.0.0'
Browse files Browse the repository at this point in the history
* (#31) Added possibility to save user metrics (a.k.a. arbitrary values)
  * `#include <easy/arbitrary_value.h>`
  * Use `EASY_VALUE("Name", variable_ref);` // See more options at `easy/arbitrary_value.h`
* Added file converter (currently only .prof to .json is supported)
* (#75) There is no need anymore to wait all threads finish their opened frames when dumping blocks to file/stream
* (#81) Added CMake option to choose function names format
* Added CMake option `EASY_PROFILER_NO_GUI` to build without `profiler_gui`
* (#48) Minimized paddings in .prof file header
* Bug fixes
  * Fixed `EASY_ENABLE_ALIGNMENT` build error
  * (#75) Fixed UI freeze when hitting `Cancel` button while transmitting profiled blocks from profiled application to the UI
  * Mac: Added support for building with Apple LLVM clang version < 8.0
    * Add support for building with pre 2016 Apple LLVM clang
    * Automatically detect Apple clang that do not support thread_local
    * Clarify clang thread_local support code comment
  * (#72) Windows: VS2017 build fix
  * Unix: Context switch logger gets the processor cycle counter instead of time of a day
  * Other bug fixes

* (#31) Added arbitrary values viewer
* (#100) Added possibility to zoom in selected region
* (#91) Added possibility to take a snapshot. Now you can save selected area to separate file. Works both with blue selection (hold right mouse button + move) and black ruler (double-click + hold mouse button + move)
* Improved UI styles
* Blocks histogram (under Diagram scene) is now resizeable
* (#89) Added viewport info widget. See [Settings] -> [See viewport info]
* Bug fixes
  * Fixed hierarchy building for zero duration blocks - events and arbitrary values are always visible
  * (#89) Trying to fix high-dpi displays problem (maybe not fixed 😞 )
  * Other bug fixes
  • Loading branch information
cas4ey committed Apr 27, 2018
2 parents 0c3dbe9 + 7761364 commit f2134ed
Show file tree
Hide file tree
Showing 160 changed files with 29,370 additions and 6,218 deletions.
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 100
IndentWidth: 4
ReflowComments: false
#IndentPPDirectives: PPDIS_AfterHash #since clang 6.0
...

17 changes: 6 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,12 @@ install:
sudo apt-get -y install qt55tools qt55script qt55base qt55svg;
else
brew install gcc5;
brew install qt5;
brew link --force qt5;
export HOMEBREW_QT5_VERSION=$(brew list --versions qt5 | rev | cut -d' ' -f1 | rev);
ln -s /usr/local/Cellar/qt/$HOMEBREW_QT5_VERSION/mkspecs /usr/local/mkspecs;
ln -s /usr/local/Cellar/qt/$HOMEBREW_QT5_VERSION/plugins /usr/local/plugins;
echo "ls -l /usr/local/mkspecs";
ls -l /usr/local/mkspecs;
echo "ls -l /usr/local/plugins";
ls -l /usr/local/plugins;
echo "/usr/local/Cellar/qt/";
ls -l /usr/local/Cellar/qt/;
brew install qt55;
brew link --force qt55;
export QT_NAME="[email protected]";
export HOMEBREW_QT5_VERSION=$(brew list --versions $QT_NAME | rev | cut -d' ' -f1 | rev);
ln -s /usr/local/Cellar/$QT_NAME/$HOMEBREW_QT5_VERSION/mkspecs /usr/local/mkspecs;
ln -s /usr/local/Cellar/$QT_NAME/$HOMEBREW_QT5_VERSION/plugins /usr/local/plugins;
fi


Expand Down
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
cmake_minimum_required(VERSION 2.8.12.1)
cmake_minimum_required(VERSION 3.0)
project(easy_profiler CXX)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(EASY_PROGRAM_VERSION_MAJOR 1)
set(EASY_PROGRAM_VERSION_MINOR 3)
option(EASY_PROFILER_NO_GUI "Build easy_profiler without the GUI application (required Qt)" OFF)

set(EASY_PROGRAM_VERSION_MAJOR 2)
set(EASY_PROGRAM_VERSION_MINOR 0)
set(EASY_PROGRAM_VERSION_PATCH 0)
set(EASY_PRODUCT_VERSION_STRING "${EASY_PROGRAM_VERSION_MAJOR}.${EASY_PROGRAM_VERSION_MINOR}.${EASY_PROGRAM_VERSION_PATCH}")

Expand All @@ -26,7 +28,10 @@ endmacro()
SET(CMAKE_INSTALL_RPATH "$ORIGIN")

add_subdirectory(easy_profiler_core)
add_subdirectory(profiler_gui)
if (NOT EASY_PROFILER_NO_GUI)
add_subdirectory(profiler_gui)
endif()
add_subdirectory(easy_profiler_converter)

if (NOT EASY_PROFILER_NO_SAMPLES)
add_subdirectory(sample)
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016-2018 Sergey Yagovtsev, Victor Zarubkin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion LICENSE.MIT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017 Sergey Yagovtsev, Victor Zarubkin
Copyright (c) 2016-2018 Sergey Yagovtsev, Victor Zarubkin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
# easy_profiler [![1.3.0](https://img.shields.io/badge/version-1.3.0-009688.svg)](https://github.com/yse/easy_profiler/releases)
# easy_profiler [![2.0.0](https://img.shields.io/badge/version-2.0.0-009688.svg)](https://github.com/yse/easy_profiler/releases)

[![Build Status](https://travis-ci.org/yse/easy_profiler.svg?branch=develop)](https://travis-ci.org/yse/easy_profiler)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/yse/easy_profiler?branch=develop&svg=true)](https://ci.appveyor.com/project/yse/easy-profiler/branch/develop)

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)

# Status
Branch `develop` contains all v2.0.0 features and new UI style.

Please, note that .prof file header has changed in v2.0.0.
Now it is:
```cpp
struct EasyFileHeader
{
uint32_t signature = 0;
uint32_t version = 0;
profiler::processid_t pid = 0;
int64_t cpu_frequency = 0;
profiler::timestamp_t begin_time = 0;
profiler::timestamp_t end_time = 0;

// Changed order of memory_size and blocks_number relative to v1.3.0
uint64_t memory_size = 0;
uint64_t descriptors_memory_size = 0;
uint32_t total_blocks_number = 0;
uint32_t total_descriptors_number = 0;
};
```

1. [About](#about)
2. [Key features](#key-features)
Expand All @@ -20,6 +42,7 @@
- [Note about context-switch](#note-about-context-switch)
4. [Build](#build)
- [Linux](#linux)
- [MacOS](#macos)
- [Windows](#windows)
5. [License](#license)

Expand All @@ -44,6 +67,9 @@ You can see the results of measuring in simple GUI application which provides fu
![GUI screenshot](https://cloud.githubusercontent.com/assets/1775230/24852044/a0b1edd0-1dde-11e7-8736-7052b840ad06.png)
_Profiling CryEngine SDK example_

![New UI Style](https://user-images.githubusercontent.com/10530007/39360172-d8e007cc-4a25-11e8-904a-75a47e388401.png)
_New UI style in version 2.0_

# Key features

- Extremely low overhead
Expand Down Expand Up @@ -135,7 +161,7 @@ void bar() {
```
## Collect blocks

There are two ways to cature blocks
There are two ways to capture blocks

### Collect via network

Expand Down Expand Up @@ -170,6 +196,8 @@ To capture a thread context-switch event you need:
```
APPLICATION_NAME - name of profiling application

There are some known issues on a linux based systems (for more information see [wiki](https://github.com/yse/easy_profiler/wiki/Known-bugs-and-issues))

# Build

## Prerequisites
Expand All @@ -190,6 +218,15 @@ $ cmake -DCMAKE_BUILD_TYPE="Release" ..
$ make
```

## MacOS

```bash
$ mkdir build
$ cd build
$ cmake -DCMAKE_CXX_COMPILER=g++-5 -DCMAKE_C_COMPILER=gcc-5 -DCMAKE_BUILD_TYPE="Release" ..
$ make
```

## Windows

If you are using QtCreator IDE you can just open `CMakeLists.txt` file in root directory.
Expand Down
23 changes: 23 additions & 0 deletions easy_profiler_converter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(CPP_FILES
converter.cpp
reader.cpp)

set(HEADER_FILES
converter.h
reader.h)

include_directories(../easy_profiler_core/)
include_directories(./include)

add_executable(profiler_converter ${HEADER_FILES} ${CPP_FILES} main.cpp)
target_link_libraries(profiler_converter easy_profiler)

install(
TARGETS
profiler_converter
RUNTIME
DESTINATION
bin
)

set_property(TARGET profiler_converter PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
138 changes: 138 additions & 0 deletions easy_profiler_converter/converter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/**
Lightweight profiler library for c++
Copyright(C) 2016-2018 Sergey Yagovtsev, Victor Zarubkin
Licensed under either of
* MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT)
* Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
The Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**/

#include "converter.h"
#include <fstream>

void JsonExporter::convert(const profiler::reader::BlocksTreeNode& node, nlohmann::json& json) const
{
if (node.info.descriptor != nullptr)
{
json = {{"id", node.info.blockIndex},
{"name", node.info.descriptor->blockName},
{"start", node.info.beginTime},
{"stop", node.info.endTime},
{"descriptor", node.info.descriptor->id}};
}

convertChildren(node, json);
}

void JsonExporter::convertChildren(const profiler::reader::BlocksTreeNode& node, nlohmann::json& json) const
{
if (node.children.empty())
return;

auto children = nlohmann::json::array();
for (const auto& child : node.children)
{
children.emplace_back();
convert(child, children.back());
}

json["children"] = children;
}

void JsonExporter::convert(const ::std::string& inputFile, const ::std::string& outputFile) const
{
profiler::reader::FileReader fr;
if (fr.readFile(inputFile) == 0)
return;

nlohmann::json json = {{"version", fr.getVersionString()}, {"timeUnits", "ns"}};

auto descriptors = nlohmann::json::array();
const auto& block_descriptors = fr.getBlockDescriptors();
for (const auto& descriptor : block_descriptors)
{
descriptors.emplace_back();

std::stringstream stream;
stream << "0x" << std::hex << descriptor.argbColor;

auto& desc = descriptors.back();

desc["id"] = descriptor.id;
if (descriptor.parentId != descriptor.id)
desc["parentId"] = descriptor.parentId;

desc["name"] = descriptor.blockName;
desc["type"] = descriptor.blockType;
desc["color"] = stream.str();
desc["sourceFile"] = descriptor.fileName;
desc["sourceLine"] = descriptor.lineNumber;
}

json["blockDescriptors"] = descriptors;

auto threads = nlohmann::json::array();
const auto& blocks_tree = fr.getBlocksTree();
for (const auto& kv : blocks_tree)
{
threads.emplace_back();

auto& thread = threads.back();
thread["threadId"] = kv.first;
thread["threadName"] = fr.getThreadName(kv.first);

convertChildren(kv.second, thread);
}

json["threads"] = threads;

try
{
if (!outputFile.empty())
{
::std::ofstream file(outputFile);
json.dump(file, true, 1);
}
else
{
json.dump(::std::cout, true, 1);
}
}
catch (...)
{
::std::cout << "json.dump() error...";
}
}
Loading

0 comments on commit f2134ed

Please sign in to comment.