ITABaseProfilerJSONTest.cpp 604 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#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;
}