mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Add support for reading TRACY_SAMPLING_HZ from an env variable.
This commit is contained in:
parent
ffb98a9724
commit
fb18a81d79
@ -16,16 +16,25 @@
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
static constexpr int GetSamplingFrequency()
|
||||
static int GetSamplingFrequency()
|
||||
{
|
||||
int samplingHz = TRACY_SAMPLING_HZ;
|
||||
|
||||
auto env = GetEnvVar( "TRACY_SAMPLING_HZ" );
|
||||
if( env )
|
||||
{
|
||||
int val = atoi( env );
|
||||
if( val > 0 ) samplingHz = val;
|
||||
}
|
||||
|
||||
#if defined _WIN32
|
||||
return TRACY_SAMPLING_HZ > 8000 ? 8000 : ( TRACY_SAMPLING_HZ < 1 ? 1 : TRACY_SAMPLING_HZ );
|
||||
return samplingHz > 8000 ? 8000 : ( samplingHz < 1 ? 1 : samplingHz );
|
||||
#else
|
||||
return TRACY_SAMPLING_HZ > 1000000 ? 1000000 : ( TRACY_SAMPLING_HZ < 1 ? 1 : TRACY_SAMPLING_HZ );
|
||||
return samplingHz > 1000000 ? 1000000 : ( samplingHz < 1 ? 1 : samplingHz );
|
||||
#endif
|
||||
}
|
||||
|
||||
static constexpr int GetSamplingPeriod()
|
||||
static int GetSamplingPeriod()
|
||||
{
|
||||
return 1000000000 / GetSamplingFrequency();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user