Commit 085b2619 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Add test for profiler json output

parent c30395db
...@@ -94,6 +94,15 @@ if (ITA_BASE_WITH_JSON_SUPPORT) ...@@ -94,6 +94,15 @@ if (ITA_BASE_WITH_JSON_SUPPORT)
set_property (TARGET ITABaseUtilsJSONTest PROPERTY FOLDER "Tests/ITABase") set_property (TARGET ITABaseUtilsJSONTest PROPERTY FOLDER "Tests/ITABase")
install (TARGETS ITABaseUtilsJSONTest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install (TARGETS ITABaseUtilsJSONTest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# ######################################################################################################################
add_executable (ITABaseProfilerJSONTest ITABaseProfilerJSONTest.cpp)
target_link_libraries (ITABaseProfilerJSONTest PUBLIC ITABase::ITABase)
set_property (TARGET ITABaseProfilerJSONTest PROPERTY FOLDER "Tests/ITABase")
install (TARGETS ITABaseProfilerJSONTest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif () endif ()
# ###################################################################################################################### # ######################################################################################################################
......
#include <ITAProfiler/profiler.h>
#include <fstream>
#include <iostream>
#include <sstream>
int main ( int nArgsIn, char** pccArgs )
{
ITA_PROFILER_NAME_THREAD_MAIN ( );
ITA_PROFILER_FUNCTION ( );
ITA_PROFILER_SECTION ( "Loop" );
for ( auto i = 0; i < 10; i++ )
{
ITA_PROFILER_EVENT_COUNT ( "event" )
ITA_PROFILER_VALUE ( "i", i )
}
ITA_PROFILER_END_SECTION ( );
try
{
std::ofstream myfile;
myfile.open ( "example.json" );
myfile << ITAProfiler::ProfilerToJson ( ).str ( );
myfile.close ( );
}
catch ( const std::exception& e )
{
std::cout << e.what ( );
}
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment