first commit

This commit is contained in:
2026-06-22 11:49:35 +02:00
commit d805f2ba86
619 changed files with 126873 additions and 0 deletions

View File

@ -0,0 +1,51 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NBENCHMARK__
#define __NBENCHMARK__
#include "time/ntime.h"
#include "container/smart_median_average.h"
namespace GS {
/*!
@short Benchmark.
@author Emmanuel Julien (ejulien@owloh.com)
*/
class Benchmark
{
SmartMedianAverage <float> avg;
Time r_clock, t_clock;
public:
void Start();
void Stop();
float GetMs() const;
void Reset();
Benchmark(bool start = false);
};
/// Scoped benchmark.
struct ScopedBenchmark
{
Benchmark &bench;
ScopedBenchmark(Benchmark &b) : bench(b)
{ bench.Start(); }
~ScopedBenchmark()
{ bench.Stop(); }
};
} // GS
#endif // __NBENCHMARK__

View File

@ -0,0 +1,42 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NLOOPBENCHMARK__
#define __NLOOPBENCHMARK__
#include "time/ntime.h"
namespace GS {
/*!
@short Loop benchmark tool.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
class LoopBenchmark
{
uint loop_count;
Time r_time, t_time;
float ms;
public:
void MarkLoop();
float GetMs() const;
float GetFps() const;
void Reset();
LoopBenchmark() : loop_count(0), ms(0) {}
};
} // GS
#endif // __NLOOPBENCHMARK__

View File

@ -0,0 +1,77 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NPROFILER__
#define __NPROFILER__
#include "timing/benchmark.h"
namespace GS {
/*!
@short Profiler.
@author Emmanuel Julien (ejulien@owloh.com)
*/
struct Profiler
{
// System is owned by the profiler.
struct System
{
String label;
Benchmark profile;
AutoList <System *> sub_systems;
void Reset()
{
profile.Reset();
ListForeachPtr(System *, s, sub_systems)
s->Reset();
}
};
AutoList <System *> root_systems;
/*!
@short Declare a system.
The system can be declared as a sub-system of another system.
*/
System *DeclareSystem(const char *label, System *subsystem_of = 0)
{
System *sys = new System;
if (sys == 0)
return 0;
sys->label = label;
if (subsystem_of)
subsystem_of->sub_systems.Add(sys);
else
root_systems.Add(sys);
return sys;
}
/// Reset all system in the profiler.
virtual void ResetProfiles()
{
ListForeachPtr(System *, s, root_systems)
s->Reset();
}
};
#if __ENGINE_RETAIL__
#define ScopedSystemProfile(_System) ;
#else
#define ScopedSystemProfile(_System) ScopedBenchmark _scoped_profile(_System->profile);
#endif
} // GS
#endif // __NPROFILER__