Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
rewrote the hole shebang to c language! this is extremely untested.
Browse files Browse the repository at this point in the history
  • Loading branch information
aidinabedi committed Dec 13, 2009
1 parent 0ff830a commit 47727b8
Show file tree
Hide file tree
Showing 27 changed files with 1,398 additions and 1,899 deletions.
21 changes: 0 additions & 21 deletions Shiny_vs2003.sln

This file was deleted.

20 changes: 0 additions & 20 deletions Shiny_vs2005.sln

This file was deleted.

29 changes: 23 additions & 6 deletions include/ShinyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,33 @@ applications, and to alter it and redistribute it freely, subject to the followi

//-----------------------------------------------------------------------------

#ifndef SHINY_PROFILER
#define SHINY_PROFILER TRUE
// SHINY_COMPILED is the master on or off swith at compile time. Define it to TRUE or FALSE before including header Shiny.h or inside ShinyConfig.h. Default is TRUE.
#ifndef SHINY_COMPILED
#define SHINY_COMPILED TRUE
#endif

#ifndef SHINY_PROFILER_LOOKUPRATE
#define SHINY_PROFILER_LOOKUPRATE FALSE
// if SHINY_LOOKUP_RATE is defined to TRUE then Shiny will record the success of its hash function. This is useful for debugging. Default is FALSE.
#ifndef SHINY_LOOKUP_RATE
#define SHINY_LOOKUP_RATE FALSE
#endif

#ifndef SHINY_PROFILER_HASENABLED
#define SHINY_PROFILER_HASENABLED FALSE
// if SHINY_HAS_ENABLED is defined to TRUE then Shiny can be enabled and disabled at runtime. TODO: bla bla...
#ifndef SHINY_HAS_ENABLED
#define SHINY_HAS_ENABLED FALSE
#endif

// TODO:
#define SHINY_OUTPUT_MODE_FLAT 0x1

// TODO:
#define SHINY_OUTPUT_MODE_TREE 0x2

// TODO:
#define SHINY_OUTPUT_MODE_BOTH 0x3

// TODO:
#ifndef SHINY_OUTPUT_MODE
#define SHINY_OUTPUT_MODE SHINY_OUTPUT_MODE_BOTH
#endif


Expand Down
114 changes: 58 additions & 56 deletions include/ShinyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,66 +26,68 @@ applications, and to alter it and redistribute it freely, subject to the followi

#include "ShinyPrereqs.h"

namespace Shiny {


//-----------------------------------------------------------------------------

struct ProfileLastData {
uint32_t entryCount;
tick_t selfTicks;
};


//-----------------------------------------------------------------------------

struct ProfileData {

template <typename T>
struct Data {
T cur;
float avg;

void computeAverage(float a_damping) { avg = a_damping * (avg - cur) + cur; }
void copyAverage(void) { avg = (float) cur; }
void clear(void) { cur = 0; avg = 0; }
};

typedef struct {
uint32_t entryCount;
tick_t selfTicks;
} ShinyLastData;

Data<uint32_t> entryCount;
Data<tick_t> selfTicks;
Data<tick_t> childTicks;


tick_t totalTicksCur(void) const { return selfTicks.cur + childTicks.cur; }
float totalTicksAvg(void) const { return selfTicks.avg + childTicks.avg; }

void computeAverage(float a_damping) {
entryCount.computeAverage(a_damping);
selfTicks.computeAverage(a_damping);
childTicks.computeAverage(a_damping);
}

void copyAverage(void) {
entryCount.copyAverage();
selfTicks.copyAverage();
childTicks.copyAverage();
}

void clearAll(void) {
entryCount.clear();
selfTicks.clear();
childTicks.clear();
}

void clearCurrent(void) {
entryCount.cur = 0;
selfTicks.cur = 0;
childTicks.cur = 0;
}
};

//-----------------------------------------------------------------------------

} // namespace Shiny
typedef struct {
tick_t cur;
float avg;
} ShinyTickData;

typedef struct {
uint32_t cur;
float avg;
} ShinyCountData;

typedef struct {
ShinyCountData entryCount;
ShinyTickData selfTicks;
ShinyTickData childTicks;
} ShinyData;

SHINY_INLINE tick_t ShinyData_totalTicksCur(const ShinyData *self) {
return self->selfTicks.cur + self->childTicks.cur;
}

SHINY_INLINE float ShinyData_totalTicksAvg(const ShinyData *self) {
return self->selfTicks.avg + self->childTicks.avg;
}

SHINY_INLINE void ShinyData_computeAverage(ShinyData *self, float a_damping) {
self->entryCount.avg = self->entryCount.cur +
a_damping * (self->entryCount.avg - self->entryCount.cur);
self->selfTicks.avg = self->selfTicks.cur +
a_damping * (self->selfTicks.avg - self->selfTicks.cur);
self->childTicks.avg = self->childTicks.cur +
a_damping * (self->childTicks.avg - self->childTicks.cur);
}

SHINY_INLINE void ShinyData_copyAverage(ShinyData *self) {
self->entryCount.avg = (float) self->entryCount.cur;
self->selfTicks.avg = (float) self->selfTicks.cur;
self->childTicks.avg = (float) self->childTicks.cur;
}

SHINY_INLINE void ShinyData_clearAll(ShinyData *self) {
self->entryCount.cur = 0;
self->entryCount.avg = 0;
self->selfTicks.cur = 0;
self->selfTicks.avg = 0;
self->childTicks.cur = 0;
self->childTicks.avg = 0;
}

SHINY_INLINE void ShinyData_clearCurrent(ShinyData *self) {
self->entryCount.cur = 0;
self->selfTicks.cur = 0;
self->childTicks.cur = 0;
}

#endif // ifndef SHINY_*_H
6 changes: 3 additions & 3 deletions include/ShinyDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ applications, and to alter it and redistribute it freely, subject to the followi
3. This notice may not be removed or altered from any source distribution.
*/

#ifndef SHINY_PROFILER // do not include this file
#ifndef SHINY_COMPILED // do not include this file


//-----------------------------------------------------------------------------
Expand All @@ -38,7 +38,7 @@ Shiny is a low overhead, well documented and lightning fast C++ profiler. Easy t
\n
\subsection sub-1 What is this document?
\ref ShinyDoc.h is a complete description of all the Shiny macros. Macro is a preprocessor directive that provides a mechanism for token replacement in your source code. Shiny uses macros to simplify interface and remain powerful. If the preprocessor SHINY_PROFILER is FALSE macro is ignored unless specified otherwise.
\ref ShinyDoc.h is a complete description of all the Shiny macros. Macro is a preprocessor directive that provides a mechanism for token replacement in your source code. Shiny uses macros to simplify interface and remain powerful. If the preprocessor SHINY_COMPILED is FALSE macro is ignored unless specified otherwise.
\n
\subsection sub2 Why did you create Shiny?
Expand Down Expand Up @@ -68,7 +68,7 @@ Where are some key features:
\n
\subsection sub5 How to switch Shiny on and off?
Shiny is turned on or off at compile time. Define the pre-processor SHINY_PROFILER to TRUE or FALSE to enable or disable, before including header Shiny.h. Shiny can also be enabled or disabled in ShinyConfig.h. Default is on.
Shiny is turned on or off at compile time. Define the pre-processor SHINY_COMPILED to TRUE or FALSE to enable or disable, before including header Shiny.h. Shiny can also be enabled or disabled in ShinyConfig.h. Default is on.
\n
\subsection sub6 Does Shiny support C language?
Expand Down
44 changes: 22 additions & 22 deletions include/ShinyMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,46 @@ applications, and to alter it and redistribute it freely, subject to the followi

#include "ShinyManager.h"

#if SHINY_PROFILER == TRUE
#if SHINY_COMPILED == TRUE


//-----------------------------------------------------------------------------
// public preprocessors

#define PROFILE_UPDATE_ALL \
Shiny::ProfileManager::instance.update
Shiny::ShinyManager::instance.update

#define PROFILE_OUTPUT_ALL \
Shiny::ProfileManager::instance.output
Shiny::ShinyManager::instance.output

#define PROFILE_GET_TREE_OUTPUT() \
Shiny::ProfileManager::instance.outputNodesAsString()
Shiny::ShinyManager::instance.outputNodesAsString()

#define PROFILE_GET_FLAT_OUTPUT() \
Shiny::ProfileManager::instance.outputZonesAsString()
Shiny::ShinyManager::instance.outputZonesAsString()

#define PROFILE_DESTROY_ALL() \
Shiny::ProfileManager::instance.destroy()
Shiny::ShinyManager::instance.destroy()

#define PROFILE_CLEAR() \
Shiny::ProfileManager::instance.clear()
Shiny::ShinyManager::instance.clear()

#define PROFILE_SORT_ZONES() \
Shiny::ProfileManager::instance.sortZones()
Shiny::ShinyManager::instance.sortZones()


//-----------------------------------------------------------------------------
// public preprocessor

#define PROFILE_GET_ROOT_DATA() \
Shiny::ProfileManager::instance.rootZone.data
Shiny::ShinyManager::instance.rootZone.data


//-----------------------------------------------------------------------------
// public preprocessor

#define PROFILE_END() \
Shiny::ProfileManager::instance._endCurNode()
ShinyManager_endCurNode(Shiny_instance)


//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -160,9 +160,9 @@ applications, and to alter it and redistribute it freely, subject to the followi
//-----------------------------------------------------------------------------
// public preprocessor

#if SHINY_PROFILER_HASENABLED == TRUE
#if SHINY_HAS_ENABLED == TRUE
#define PROFILE_SET_ENABLED( boolean ) \
Shiny::ProfileManager::instance.enabled = boolean
Shiny::ShinyManager::instance.enabled = boolean
#endif


Expand All @@ -181,8 +181,8 @@ applications, and to alter it and redistribute it freely, subject to the followi

#define _PROFILE_ZONE_DEFINE( id, string ) \
\
Shiny::ProfileZone id = { \
NULL, Shiny::ProfileZone::STATE_HIDDEN, string, \
Shiny::ShinyZone id = { \
NULL, SHINY_ZONE_STATE_HIDDEN, string, \
{ { 0, 0 }, { 0, 0 }, { 0, 0 } } \
}

Expand All @@ -192,15 +192,15 @@ applications, and to alter it and redistribute it freely, subject to the followi

#define _PROFILE_ZONE_DECLARE( prefix, id ) \
\
prefix Shiny::ProfileZone id
prefix Shiny::ShinyZone id


//-----------------------------------------------------------------------------
// internal preprocessor

#define _PROFILE_BLOCK_DEFINE( id ) \
\
Shiny::ProfileAutoEndNode SHINY_UNUSED id
Shiny::ShinyEndNodeOnDestruction SHINY_UNUSED id


//-----------------------------------------------------------------------------
Expand All @@ -209,19 +209,19 @@ applications, and to alter it and redistribute it freely, subject to the followi
#define _PROFILE_ZONE_BEGIN( id ) \
{ \
static Shiny::ProfileNodeCache cache = \
&Shiny::ProfileNode::_dummy; \
&ShinyNode_dummy; \
\
Shiny::ProfileManager::instance._beginNode(&cache, &id); \
ShinyManager_lookupAndBeginNode(Shiny_instance, &cache, &id); \
}

//-----------------------------------------------------------------------------

#else // #if SHINY_PROFILER == TRUE
#else // #if SHINY_COMPILED == TRUE

namespace Shiny {

SHINY_INLINE ProfileData GetEmptyData() {
ProfileData a = { { 0, 0 }, { 0, 0 }, { 0, 0 } };
SHINY_INLINE ShinyData GetEmptyData() {
ShinyData a = { { 0, 0 }, { 0, 0 }, { 0, 0 } };
return a;
}
}
Expand All @@ -244,7 +244,7 @@ namespace Shiny {
#define PROFILE_GET_SHARED_DATA(name) Shiny::GetEmptyData()
#define PROFILE_GET_ROOT_DATA() Shiny::GetEmptyData()

#if SHINY_PROFILER_HASENABLED == TRUE
#if SHINY_HAS_ENABLED == TRUE
#define PROFILE_SET_ENABLED(boolean)
#endif

Expand Down
Loading

0 comments on commit 47727b8

Please sign in to comment.