<commit_before>/*
 *   CrissCross
 *   A multi-purpose cross-platform library.
 *
 *   A product of Uplink Laboratories.
 *
 *   (c) 2006-2010 <NAME>.
 *   Licensed under the New BSD License.
 *
 */

#ifndef __included_cc_profiler_h
#define __included_cc_profiler_h

#include <crisscross/cc_attr.h>
#include <crisscross/hashtable.h>
#include <crisscross/llist.h>

namespace CrissCross
{
	namespace System
	{
		class Profiler;

		class ProfiledElement
		{
		private:
			Profiler  *m_profiler;

		public:
			/* Values used for accumulating the profile for the current second */
			double     m_currentTotalTime; /* In seconds */
			int        m_currentNumCalls;

			/* Values used for storing the profile for the previous second */
			double     m_lastTotalTime; /* In seconds */
			int        m_lastNumCalls;

			/* Values used for storing history data (accumulation of all m_lastTotalTime */
			/* and m_lastNumCalls values since last reset) */
			double     m_historyTotalTime; /* In seconds */
			double     m_historyNumSeconds;
			int        m_historyNumCalls;

			/* Values used for storing the longest and shortest duration spent inside */
			/* this elements profile. These values are reset when the history is reset */
			double     m_shortest;
			double     m_longest;

			double     m_callStartTime;
			char      *m_name;

			CrissCross::Data::SortingHashTable<ProfiledElement *> m_children;
			ProfiledElement                            *m_parent;

			bool       m_isExpanded; /* Bit of data that a tree view display can use */
			bool       m_wasExpanded;

		public:
			ProfiledElement(char const *_name, ProfiledElement *_parent, Profiler *_profiler);
			~ProfiledElement();

			void Start();
			void End();
			void Advance();
			void ResetHistory();

			double GetMaxChildTime();
		};


		class Profiler
		{
		protected:
			bool m_inRenderSection;

			bool IsMasterThread();

		// TODO: Making these public is a bad practice. Find a more appropriate way to do this.
		public:
			ProfiledElement	*m_currentElement;
			ProfiledElement	*m_rootElement;
			double           m_endOfSecond;
			double           m_lengthOfLastSecond;
			bool             m_doGlFinish;
			#ifdef TARGET_OS_WINDOWS
			DWORD            m_masterThread;
			#else
			pthread_t        m_masterThread;
			#endif<commit_msg>profiler: fix compilation on Windows<commit_after>/*
 *   CrissCross
 *   A multi-purpose cross-platform library.
 *
 *   A product of Uplink Laboratories.
 *
 *   (c) 2006-2010 <NAME>.
 *   Licensed under the New BSD License.
 *
 */

#ifndef __included_cc_profiler_h
#define __included_cc_profiler_h

#include <crisscross/cc_attr.h>
#include <crisscross/hashtable.h>
#include <crisscross/llist.h>

namespace CrissCross
{
	namespace System
	{
		class Profiler;

		class ProfiledElement
		{
		private:
			Profiler  *m_profiler;

		public:
			/* Values used for accumulating the profile for the current second */
			double     m_currentTotalTime; /* In seconds */
			int        m_currentNumCalls;

			/* Values used for storing the profile for the previous second */
			double     m_lastTotalTime; /* In seconds */
			int        m_lastNumCalls;

			/* Values used for storing history data (accumulation of all m_lastTotalTime */
			/* and m_lastNumCalls values since last reset) */
			double     m_historyTotalTime; /* In seconds */
			double     m_historyNumSeconds;
			int        m_historyNumCalls;

			/* Values used for storing the longest and shortest duration spent inside */
			/* this elements profile. These values are reset when the history is reset */
			double     m_shortest;
			double     m_longest;

			double     m_callStartTime;
			char      *m_name;

			CrissCross::Data::SortingHashTable<ProfiledElement *> m_children;
			ProfiledElement                            *m_parent;

			bool       m_isExpanded; /* Bit of data that a tree view display can use */
			bool       m_wasExpanded;

		public:
			ProfiledElement(char const *_name, ProfiledElement *_parent, Profiler *_profiler);
			~ProfiledElement();

			void Start();
			void End();
			void Advance();
			void ResetHistory();

			double GetMaxChildTime();
		};


		class Profiler
		{
		protected:
			bool m_inRenderSection;

			bool IsMasterThread();

		// TODO: Making these public is a bad practice. Find a more appropriate way to do this.
		public:
			ProfiledElement	*m_currentElement;
			ProfiledElement	*m_rootElement;
			double           m_endOfSecond;
			double           m_lengthOfLastSecond;
			bool             m_doGlFinish;
			#ifdef TARGET_OS_WINDOWS
			unsigned int     m_masterThread;
			#else
			pthread_t        m_masterThread;
			#endif
{'fraction_non_alphanumeric': 0.07453013609850939, 'fraction_numerical': 0.0034564700799308706, 'mean_word_length': 2.779591836734694, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3685217', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1395, 'n_words': 420}