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

Commit

Permalink
added ShinyLua + new sorting alg
Browse files Browse the repository at this point in the history
  • Loading branch information
aidinabedi committed Dec 21, 2009
1 parent 46db807 commit a19935f
Show file tree
Hide file tree
Showing 17 changed files with 699 additions and 152 deletions.
1 change: 0 additions & 1 deletion Samples/Advanced/Advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ THE SOFTWARE.
*/

#include "Shiny.h"
#include <stdlib.h>

#include "Shared.h"

Expand Down
3 changes: 1 addition & 2 deletions Samples/Advanced/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ THE SOFTWARE.
*/

#include "Shiny.h"
#include <stdlib.h>

#ifdef _WIN32
#include <windows.h> // Sleep
Expand Down Expand Up @@ -69,7 +68,7 @@ int main() {
#endif

PROFILE_UPDATE(); // update all profiles
PROFILE_OUTPUT(stdout); // print to terminal
PROFILE_OUTPUT(NULL); // print to terminal

#ifdef _WIN32
system("pause");
Expand Down
3 changes: 1 addition & 2 deletions Samples/MainLoop/MainLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ THE SOFTWARE.
*/

#include "Shiny.h"
#include <stdlib.h>

#ifdef _WIN32
#include <windows.h> // Sleep
Expand Down Expand Up @@ -114,7 +113,7 @@ int main() {
PROFILE_UPDATE(); // update all profiles
}

PROFILE_OUTPUT(stdout); // print to terminal
PROFILE_OUTPUT(NULL); // print to terminal

#ifdef _WIN32
system("pause");
Expand Down
3 changes: 1 addition & 2 deletions Samples/Simple/Simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ THE SOFTWARE.
*/

#include "Shiny.h"
#include <stdlib.h>

#ifdef _WIN32
#include <windows.h> // Sleep
Expand Down Expand Up @@ -72,7 +71,7 @@ int main() {
LazyHelloWorld();

PROFILE_UPDATE(); // update all profiles
PROFILE_OUTPUT(stdout); // print to terminal
PROFILE_OUTPUT(NULL); // print to terminal

#ifdef _WIN32
system("pause");
Expand Down
9 changes: 9 additions & 0 deletions Shiny.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Demo_Advanced", "Samples\Ad
{D44CCFEB-7FC2-46E6-8290-E0B00D06A636} = {D44CCFEB-7FC2-46E6-8290-E0B00D06A636}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShinyLua", "ShinyLua\scripts\ShinyLua.vcproj", "{98E8A575-2BDC-4A8C-8917-6BFF1EC660E8}"
ProjectSection(ProjectDependencies) = postProject
{D44CCFEB-7FC2-46E6-8290-E0B00D06A636} = {D44CCFEB-7FC2-46E6-8290-E0B00D06A636}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand All @@ -40,6 +45,10 @@ Global
{D0EB96F2-10EC-4DCC-AC4F-93E20D2717AC}.Debug|Win32.Build.0 = Debug|Win32
{D0EB96F2-10EC-4DCC-AC4F-93E20D2717AC}.Release|Win32.ActiveCfg = Release|Win32
{D0EB96F2-10EC-4DCC-AC4F-93E20D2717AC}.Release|Win32.Build.0 = Release|Win32
{98E8A575-2BDC-4A8C-8917-6BFF1EC660E8}.Debug|Win32.ActiveCfg = Debug|Win32
{98E8A575-2BDC-4A8C-8917-6BFF1EC660E8}.Debug|Win32.Build.0 = Debug|Win32
{98E8A575-2BDC-4A8C-8917-6BFF1EC660E8}.Release|Win32.ActiveCfg = Release|Win32
{98E8A575-2BDC-4A8C-8917-6BFF1EC660E8}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions Shiny/include/Shiny.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ THE SOFTWARE.

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

#ifdef __cplusplus
extern "C" {
#endif

#include "ShinyMacros.h"
#include "ShinyManager.h"

#ifdef __cplusplus
}
#endif

#endif // ifndef SHINY_*_H
6 changes: 5 additions & 1 deletion Shiny/include/ShinyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ THE SOFTWARE.

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

#define SHINY_VERSION "Shiny Profiler 2.5"
#define SHINY_VERSION "2.5"
#define SHINY_SHORTNAME "Shiny"
#define SHINY_FULLNAME "Shiny Profiler"
#define SHINY_COPYRIGHT "Copyright (C) 2007-2009 Aidin Abedi"
#define SHINY_DESCRIPTION "Shiny is a elegent profiler designed to help finding bottlenecks in your project."


//-----------------------------------------------------------------------------
Expand Down
24 changes: 12 additions & 12 deletions Shiny/include/ShinyMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ THE SOFTWARE.
#define PROFILE_UPDATE() \
ShinyManager_update(&Shiny_instance)

#define PROFILE_SET_DAMPING(float0to1) \
Shiny_instance.damping = (float0to1);
#define PROFILE_SET_DAMPING(from0to1) \
Shiny_instance.damping = (from0to1);

#define PROFILE_GET_DAMPING() \
(Shiny_instance.damping)

#define PROFILE_OUTPUT_FILE(filename) \
ShinyManager_outputToFile(&Shiny_instance, (filename))
#define PROFILE_OUTPUT(filename) \
ShinyManager_output(&Shiny_instance, (filename))

#define PROFILE_OUTPUT(stream) \
#define PROFILE_OUTPUT_STREAM(stream) \
ShinyManager_outputToStream(&Shiny_instance, (stream))

#ifdef __cplusplus
#define PROFILE_GET_TREE_STRING() \
ShinyManager_outputNodesToString(&Shiny_instance)
ShinyManager_outputTreeToString(&Shiny_instance)

#define PROFILE_GET_FLAT_STRING() \
ShinyManager_outputZonesToString(&Shiny_instance)
ShinyManager_outputFlatToString(&Shiny_instance)
#endif

#define PROFILE_DESTROY() \
Expand Down Expand Up @@ -103,13 +103,13 @@ THE SOFTWARE.
//-----------------------------------------------------------------------------
// public preprocessor

#define PROFILE_WATCH_SHARED_SELF(name, float0to1) \
#define PROFILE_WATCH_SHARED_SELF(name, from0to1) \
ShinyManager_isSelfZoneGreaterEqual( \
&Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), float0to1)
&Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), from0to1)

#define PROFILE_WATCH_SHARED_TOTAL(name, float0to1) \
#define PROFILE_WATCH_SHARED_TOTAL(name, from0to1) \
ShinyManager_isTotalZoneGreaterEqual( \
&Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), float0to1)
&Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), from0to1)


//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -265,8 +265,8 @@ SHINY_INLINE ShinyData GetEmptyData() {
#define PROFILE_UPDATE()
#define PROFILE_SET_DAMPING(x)
#define PROFILE_GET_DAMPING() 0.0f
#define PROFILE_OUTPUT_FILE(x)
#define PROFILE_OUTPUT(x)
#define PROFILE_OUTPUT_STREAM(x)
#define PROFILE_CLEAR()
#define PROFILE_GET_TREE_STRING() std::string()
#define PROFILE_GET_FLAT_STRING() std::string()
Expand Down
16 changes: 9 additions & 7 deletions Shiny/include/ShinyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,24 @@ SHINY_INLINE void ShinyManager_sortZones(ShinyManager *self) {

SHINY_API const char* ShinyManager_getOutputErrorString(ShinyManager *self);

SHINY_API int ShinyManager_outputToFile(ShinyManager *self, const char *a_filename);
SHINY_API int ShinyManager_output(ShinyManager *self, const char *a_filename);
SHINY_API void ShinyManager_outputToStream(ShinyManager *self, FILE *stream);

#if __cplusplus
} // end of extern "C"

SHINY_INLINE std::string ShinyManager_outputNodesToString(ShinyManager *self) {
SHINY_INLINE std::string ShinyManager_outputTreeToString(ShinyManager *self) {
const char* error = ShinyManager_getOutputErrorString(self);
if (!error) return ShinyNodesToString(&self->rootNode, self->nodeCount);
else return error;
if (error) return error;
else return ShinyNodesToString(&self->rootNode, self->nodeCount);
}

SHINY_INLINE std::string ShinyManager_outputZonesToString(ShinyManager *self) {
SHINY_INLINE std::string ShinyManager_outputFlatToString(ShinyManager *self) {
const char* error = ShinyManager_getOutputErrorString(self);
if (!error) return ShinyZonesToString(&self->rootZone, self->zoneCount);
else return error;
if (error) return error;

ShinyManager_sortZones(self);
return ShinyZonesToString(&self->rootZone, self->zoneCount);
}

extern "C" { // end of c++
Expand Down
3 changes: 3 additions & 0 deletions Shiny/include/ShinyOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ THE SOFTWARE.
SHINY_API int ShinyPrintNodesSize(uint32_t a_count);
SHINY_API int ShinyPrintZonesSize(uint32_t a_count);

SHINY_API void ShinyPrintANode(char* output, const ShinyNode *a_node, const ShinyNode *a_root);
SHINY_API void ShinyPrintAZone(char* output, const ShinyZone *a_zone, const ShinyZone *a_root);

SHINY_API void ShinyPrintNodes(char* output, const ShinyNode *a_root);
SHINY_API void ShinyPrintZones(char* output, const ShinyZone *a_root);

Expand Down
2 changes: 1 addition & 1 deletion Shiny/include/ShinyZone.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ SHINY_API void ShinyZone_resetChain(ShinyZone *first);
SHINY_API ShinyZone* ShinyZone_sortChain(ShinyZone *first);

SHINY_INLINE float ShinyZone_compare(ShinyZone *a, ShinyZone *b) {
return b->data.selfTicks.avg - a->data.selfTicks.avg;
return a->data.selfTicks.avg - b->data.selfTicks.avg;
}

SHINY_API void ShinyZone_clear(ShinyZone* self);
Expand Down
19 changes: 13 additions & 6 deletions Shiny/src/ShinyManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ShinyNode* _ShinyManager_dummyNodeTable[] = { NULL };
#endif

// primary hash function
SHINY_INLINE uint32_t hash_value(ShinyNode* a_pParent, ShinyZone* a_pZone) {
SHINY_INLINE uint32_t hash_value(void* a_pParent, void* a_pZone) {
uint32_t a = (uint32_t) a_pParent + (uint32_t) a_pZone;

a = (a+0x7ed55d16) + (a<<12);
Expand Down Expand Up @@ -178,7 +178,7 @@ void ShinyManager_destroy(ShinyManager *self) {

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

ShinyNode* _ShinyManager_lookupNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_zone) {
ShinyNode* _ShinyManager_lookupNode(ShinyManager *self, ShinyNodeCache *a_cache, ShinyZone *a_zone) {
uint32_t nHash = hash_value(self->_curNode, a_zone);
uint32_t nIndex = nHash & self->_tableMask;
ShinyNode* pNode = self->_nodeTable[nIndex];
Expand Down Expand Up @@ -382,12 +382,17 @@ const char* ShinyManager_getOutputErrorString(ShinyManager *self) {
# pragma warning (disable: 4996)
#endif

int ShinyManager_outputToFile(ShinyManager *self, const char *a_filename) {
FILE *file = fopen(a_filename, "w");
int ShinyManager_output(ShinyManager *self, const char *a_filename) {
if (!a_filename) {
ShinyManager_outputToStream(self, stdout);

ShinyManager_outputToStream(self, file);
} else {
FILE *file = fopen(a_filename, "w");
if (!file) return FALSE;
ShinyManager_outputToStream(self, file);
fclose(file);
}

fclose(file);
return TRUE;
}

Expand All @@ -408,6 +413,8 @@ void ShinyManager_outputToStream(ShinyManager *self, FILE *a_stream) {
}

#if SHINY_OUTPUT_MODE & SHINY_OUTPUT_MODE_FLAT
ShinyManager_sortZones(self);

{
int size = ShinyPrintZonesSize(self->zoneCount);
char *buffer = (char*) malloc(size);
Expand Down
Loading

0 comments on commit a19935f

Please sign in to comment.