Author: remi
Date: 2009-02-15 17:47:27 +0100 (Sun, 15 Feb 2009)
New Revision: 3636
Added:
software_suite_v2/tuxware/tuxosl-ose/trunk/include/misc.h
software_suite_v2/tuxware/tuxosl-ose/trunk/include/miscCompat.h
software_suite_v2/tuxware/tuxosl-ose/trunk/include/profiler.h
software_suite_v2/tuxware/tuxosl-ose/trunk/include/win32/miscCompat.h
software_suite_v2/tuxware/tuxosl-ose/trunk/src/misc.cpp
software_suite_v2/tuxware/tuxosl-ose/trunk/src/profiler.cpp
software_suite_v2/tuxware/tuxosl-ose/trunk/src/win32/miscCompat.cpp
Modified:
software_suite_v2/tuxware/tuxosl-ose/trunk/Makefile.win32
Log:
* added some modules (profiler and its dependencies) from my A2DE personal
project
Modified: software_suite_v2/tuxware/tuxosl-ose/trunk/Makefile.win32
===================================================================
--- software_suite_v2/tuxware/tuxosl-ose/trunk/Makefile.win32 2009-02-15
16:29:51 UTC (rev 3635)
+++ software_suite_v2/tuxware/tuxosl-ose/trunk/Makefile.win32 2009-02-15
16:47:27 UTC (rev 3636)
@@ -22,6 +22,12 @@
-...@$(CC2) -c $(CFLAGS) $(SRC_DIR)/platform_independent.cpp
$(C_INCLUDE_DIRS) -o $(OBJ_DIR)/platform_independent.o
-...@echo log
-...@$(CC2) -c $(CFLAGS) $(SRC_DIR)/log.cpp $(C_INCLUDE_DIRS) -o
$(OBJ_DIR)/log.o
+ -...@echo misc compat
+ -...@$(CC2) -c $(CFLAGS) $(SRC_DIR)/win32/miscCompat.cpp
$(C_INCLUDE_DIRS) -o $(OBJ_DIR)/miscCompat.o
+ -...@echo misc
+ -...@$(CC2) -c $(CFLAGS) $(SRC_DIR)/misc.cpp $(C_INCLUDE_DIRS) -o
$(OBJ_DIR)/misc.o
+ -...@echo profiler
+ -...@$(CC2) -c $(CFLAGS) $(SRC_DIR)/profiler.cpp $(C_INCLUDE_DIRS) -o
$(OBJ_DIR)/profiler.o
-...@echo playback
-...@$(CC2) -c $(CFLAGS) $(SRC_DIR)/win32/playback.cpp
$(C_INCLUDE_DIRS) -o $(OBJ_DIR)/playback.o
-...@echo fifo
@@ -38,7 +44,7 @@
-...@echo main cpp
-...@$(CC2) -c $(CFLAGS) ./test/main.cpp $(C_INCLUDE_DIRS) -o
$(OBJ_DIR)/main_cpp.o
-...@echo link test cpp
- -...@$(CC2) -o "$(OUTPUT_DIR)\OSL_OSE_TEST.exe" $(OBJ_DIR)/main_cpp.o
$(OBJ_DIR)/log.o $(OBJ_DIR)/playback.o $(OBJ_DIR)/fifo.o $(OBJ_DIR)/channel.o
$(OBJ_DIR)/equalizer.o $(OBJ_DIR)/mixer.o $(LIB_DIRS) $(LIBS) $(LDFLAGS)
+ -...@$(CC2) -o "$(OUTPUT_DIR)\OSL_OSE_TEST.exe" $(OBJ_DIR)/main_cpp.o
$(OBJ_DIR)/log.o $(OBJ_DIR)/miscCompat.o $(OBJ_DIR)/misc.o
$(OBJ_DIR)/profiler.o $(OBJ_DIR)/playback.o $(OBJ_DIR)/fifo.o
$(OBJ_DIR)/channel.o $(OBJ_DIR)/equalizer.o $(OBJ_DIR)/mixer.o $(LIB_DIRS)
$(LIBS) $(LDFLAGS)
-...@rm -fR $(OBJ_DIR)/*.o
-...@rmdir $(OBJ_DIR)
Added: software_suite_v2/tuxware/tuxosl-ose/trunk/include/misc.h
===================================================================
--- software_suite_v2/tuxware/tuxosl-ose/trunk/include/misc.h
(rev 0)
+++ software_suite_v2/tuxware/tuxosl-ose/trunk/include/misc.h 2009-02-15
16:47:27 UTC (rev 3636)
@@ -0,0 +1,28 @@
+/*
+ * Acness 2D Engine - Misc
+ * Copyright (C) Acness <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _MISC_H_
+#define _MISC_H_
+
+#include "miscCompat.h"
+
+unsigned long long int getTickCount(void);
+
+#endif /* _MISC_H_ */
Property changes on: software_suite_v2/tuxware/tuxosl-ose/trunk/include/misc.h
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v2/tuxware/tuxosl-ose/trunk/include/miscCompat.h
===================================================================
--- software_suite_v2/tuxware/tuxosl-ose/trunk/include/miscCompat.h
(rev 0)
+++ software_suite_v2/tuxware/tuxosl-ose/trunk/include/miscCompat.h
2009-02-15 16:47:27 UTC (rev 3636)
@@ -0,0 +1,25 @@
+/*
+ * Acness 2D Engine - Misc Compatibility
+ * Copyright (C) Acness <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifdef WIN32
+# include "win32/miscCompat.h"
+#else
+# include "unix/miscCompat.h"
+#endif
Property changes on:
software_suite_v2/tuxware/tuxosl-ose/trunk/include/miscCompat.h
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v2/tuxware/tuxosl-ose/trunk/include/profiler.h
===================================================================
--- software_suite_v2/tuxware/tuxosl-ose/trunk/include/profiler.h
(rev 0)
+++ software_suite_v2/tuxware/tuxosl-ose/trunk/include/profiler.h
2009-02-15 16:47:27 UTC (rev 3636)
@@ -0,0 +1,55 @@
+/*
+ * Acness 2D Engine - Profiler
+ * Copyright (C) Acness <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _PROFILER_H_
+#define _PROFILER_H_
+
+/**
+ * \brief Profiler section structure.
+ */
+typedef struct
+{
+ unsigned long long int timeSum;
+ unsigned long long int previousTime;
+ unsigned long int callsCount;
+ bool isStarted;
+ char name[255];
+} profilerSectionInfo;
+
+/**
+ * \brief A simple profile class.
+ */
+class engineProfiler
+{
+ public:
+ engineProfiler(const char *outputFilename);
+ ~engineProfiler();
+ void addNewSection(const char *sectionName);
+ void sectionBegin(const char *sectionName);
+ void sectionEnd(const char *sectionName);
+ private:
+ profilerSectionInfo *_sectionsList[256];
+ unsigned short int _sectionsCount;
+ char _outputFilename[255];
+ int getSectionIdFromName(const char *sectionName);
+ void computeStats();
+};
+
+#endif /* _PROFILER_H_ */
Property changes on:
software_suite_v2/tuxware/tuxosl-ose/trunk/include/profiler.h
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v2/tuxware/tuxosl-ose/trunk/include/win32/miscCompat.h
===================================================================
--- software_suite_v2/tuxware/tuxosl-ose/trunk/include/win32/miscCompat.h
(rev 0)
+++ software_suite_v2/tuxware/tuxosl-ose/trunk/include/win32/miscCompat.h
2009-02-15 16:47:27 UTC (rev 3636)
@@ -0,0 +1,39 @@
+/*
+ * Acness 2D Engine - Misc Compatibility
+ * Copyright (C) Acness <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _MISCCOMPAT_H_
+#define _MISCCOMPAT_H_
+
+#include <windows.h>
+
+#define sleep(sec) Sleep(sec * 1000)
+#define usleep(usec) Sleep(usec / 1000)
+#define LIBEXPORT __declspec(dllexport)
+#define LIBLOCAL
+
+struct timezone
+{
+ int tz_minuteswest; /* minutes W of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
+int gettimeofday(struct timeval *tv, struct timezone *tz);
+
+#endif /* _MISCCOMPAT_H_ */
Property changes on:
software_suite_v2/tuxware/tuxosl-ose/trunk/include/win32/miscCompat.h
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v2/tuxware/tuxosl-ose/trunk/src/misc.cpp
===================================================================
--- software_suite_v2/tuxware/tuxosl-ose/trunk/src/misc.cpp
(rev 0)
+++ software_suite_v2/tuxware/tuxosl-ose/trunk/src/misc.cpp 2009-02-15
16:47:27 UTC (rev 3636)
@@ -0,0 +1,35 @@
+/*
+ * Acness 2D Engine - Misc
+ * Copyright (C) Acness <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "../include/misc.h"
+
+/**
+ * \brief Get the current cpu tick counts (in usec)
+ * \return The tick counts.
+ */
+unsigned long long int
+getTickCount(void)
+{
+ struct timeval tv;
+ struct timezone tz;
+
+ gettimeofday(&tv, &tz);
+ return (tv.tv_sec * 1000000 + tv.tv_usec);
+}
Property changes on: software_suite_v2/tuxware/tuxosl-ose/trunk/src/misc.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v2/tuxware/tuxosl-ose/trunk/src/profiler.cpp
===================================================================
--- software_suite_v2/tuxware/tuxosl-ose/trunk/src/profiler.cpp
(rev 0)
+++ software_suite_v2/tuxware/tuxosl-ose/trunk/src/profiler.cpp 2009-02-15
16:47:27 UTC (rev 3636)
@@ -0,0 +1,179 @@
+/*
+ * Acness 2D Engine - Profiler
+ * Copyright (C) Acness <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "../include/profiler.h"
+#include "../include/misc.h"
+
+/**
+ * \brief Constructor.
+ * \param outputFilename Output filename for the statistic results.
+ */
+engineProfiler::engineProfiler(const char *outputFilename)
+{
+ _sectionsCount = 0;
+ strcpy(_outputFilename, outputFilename);
+}
+
+/**
+ * \brief Destructor.
+ */
+engineProfiler::~engineProfiler()
+{
+ computeStats();
+ if (_sectionsCount)
+ {
+ for (int i = 0; i < _sectionsCount; i++)
+ {
+ delete _sectionsList[i];
+ }
+ }
+}
+
+/**
+ * \brief Add a new profiler section.
+ * \param sectionName Section name.
+ */
+void
+engineProfiler::addNewSection(const char *sectionName)
+{
+ if (getSectionIdFromName(sectionName) == -1)
+ {
+ _sectionsList[_sectionsCount] = new profilerSectionInfo;
+ strcpy(_sectionsList[_sectionsCount]->name, sectionName);
+ _sectionsList[_sectionsCount]->isStarted = false;
+ _sectionsList[_sectionsCount]->callsCount = 0;
+ _sectionsList[_sectionsCount]->timeSum = 0;
+ _sectionsCount++;
+ }
+}
+
+/**
+ * \brief Begin section.
+ * \param sectionName Section name.
+ */
+void
+engineProfiler::sectionBegin(const char *sectionName)
+{
+ int sectionId = getSectionIdFromName(sectionName);
+ if (sectionId >= 0)
+ {
+ if (!_sectionsList[sectionId]->isStarted)
+ {
+ _sectionsList[sectionId]->isStarted = true;
+ _sectionsList[sectionId]->previousTime = getTickCount();
+ }
+ }
+}
+
+/**
+ * \brief End section.
+ * \param sectionName Section name.
+ */
+void
+engineProfiler::sectionEnd(const char *sectionName)
+{
+ int sectionId = getSectionIdFromName(sectionName);
+ if (sectionId >= 0)
+ {
+ if (_sectionsList[sectionId]->isStarted)
+ {
+ _sectionsList[sectionId]->callsCount++;
+ _sectionsList[sectionId]->timeSum += (getTickCount() -
+ _sectionsList[sectionId]->previousTime);
+ _sectionsList[sectionId]->isStarted = false;
+ }
+ }
+}
+
+/**
+ * \brief Get the registred section Id from its name.
+ * \param sectionName Section name.
+ * \return The section Id or -1.
+ */
+int
+engineProfiler::getSectionIdFromName(const char *sectionName)
+{
+ if (!_sectionsCount)
+ {
+ return -1;
+ }
+ for (int i = 0; i < _sectionsCount; i++)
+ {
+ if (!strcmp(sectionName, _sectionsList[i]->name))
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+/**
+ * \brief Compute the profiler stats and write it to file.
+ */
+void
+engineProfiler::computeStats()
+{
+ unsigned long long int globalTime = 0;
+ float pCent;
+ FILE *f;
+
+ if (!_sectionsCount)
+ {
+ return;
+ }
+ for (int i = 0; i < _sectionsCount; i++)
+ {
+ globalTime += _sectionsList[i]->timeSum;
+ }
+ if (!globalTime)
+ {
+ return;
+ }
+ f = fopen(_outputFilename, "wb");
+ if (f == NULL)
+ {
+ return;
+ }
+ fprintf(f, "Profiler summary:\n");
+ fprintf(f, "----------------------------------------");
+ fprintf(f, "----------------------------------------\n");
+ fprintf(f, "%% t(ms) calls tbc(ms) section\n");
+ fprintf(f, "----------------------------------------");
+ fprintf(f, "----------------------------------------\n");
+ for (int i = 0; i < _sectionsCount; i++)
+ {
+ pCent = (float)_sectionsList[i]->timeSum / (float)globalTime;
+ pCent *= 100.;
+ fprintf(f, "[%7.3f] [%9.3f] [%6d] [%9.3f] [%s]\n",
+ pCent,
+ (float)_sectionsList[i]->timeSum / 1000.,
+ (int)_sectionsList[i]->callsCount,
+ (float)_sectionsList[i]->timeSum /
(float)_sectionsList[i]->callsCount
+ / 1000.,
+ _sectionsList[i]->name
+ );
+ }
+ fprintf(f, "----------------------------------------");
+ fprintf(f, "----------------------------------------");
+ fclose(f);
+}
Property changes on: software_suite_v2/tuxware/tuxosl-ose/trunk/src/profiler.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v2/tuxware/tuxosl-ose/trunk/src/win32/miscCompat.cpp
===================================================================
--- software_suite_v2/tuxware/tuxosl-ose/trunk/src/win32/miscCompat.cpp
(rev 0)
+++ software_suite_v2/tuxware/tuxosl-ose/trunk/src/win32/miscCompat.cpp
2009-02-15 16:47:27 UTC (rev 3636)
@@ -0,0 +1,70 @@
+/*
+ * Acness 2D Engine - Misc Compatibility
+ * Copyright (C) Acness <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <time.h>
+
+#include "../../include/win32/miscCompat.h"
+
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+# define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
+#else
+# define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
+#endif
+
+/**
+ * \brief Get the time of the day.
+ * Missing function on windows.
+ */
+int
+gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ FILETIME ft;
+ unsigned __int64 tmpres = 0;
+ static int tzflag;
+
+ if (NULL != tv)
+ {
+ GetSystemTimeAsFileTime(&ft);
+
+ tmpres |= ft.dwHighDateTime;
+ tmpres <<= 32;
+ tmpres |= ft.dwLowDateTime;
+
+ /*converting file time to unix epoch*/
+ tmpres -= DELTA_EPOCH_IN_MICROSECS;
+ tmpres /= 10; /*convert into microseconds*/
+ tv->tv_sec = (long)(tmpres / 1000000UL);
+ tv->tv_usec = (long)(tmpres % 1000000UL);
+ }
+
+ if (NULL != tz)
+ {
+ if (!tzflag)
+ {
+ _tzset();
+ tzflag++;
+ }
+ tz->tz_minuteswest = _timezone / 60;
+ tz->tz_dsttime = _daylight;
+ }
+
+ return 0;
+}
Property changes on:
software_suite_v2/tuxware/tuxosl-ose/trunk/src/win32/miscCompat.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn