File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,17 +60,12 @@ bool needTimeStatistics() {
6060}
6161
6262uint32_t getGranularityUnitsPerSecond () {
63- static const char *TimeStatisticsGranularity =
64- getenv (" AMD_COMGR_TIME_STATISTICS_GRANULARITY" );
65- if (!TimeStatisticsGranularity)
66- return 1e3 ;
67- StringRef G (TimeStatisticsGranularity);
63+ StringRef G = getTimeStatisticsGranularity ();
6864 if (G == " us" )
6965 return 1e6 ;
7066 else if (G == " ns" )
7167 return 1e9 ;
72- else
73- return 1e3 ;
68+ return 1e3 ;
7469}
7570
7671llvm::StringRef getTimeStatisticsGranularity () {
Original file line number Diff line number Diff line change @@ -29,10 +29,10 @@ bool shouldEmitVerboseLogs();
2929// / Return whether the environment requests time statistics collection.
3030bool needTimeStatistics ();
3131
32- // Return granularity (ms, us, ns) units per second
32+ // / Return granularity (ms, us, ns) units per second
3333uint32_t getGranularityUnitsPerSecond ();
3434
35- // Return granularity of time statistics (ms, us, ns)
35+ // / Return granularity of time statistics (ms, us, ns)
3636llvm::StringRef getTimeStatisticsGranularity ();
3737
3838// / If environment variable LLVM_PATH is set, return the environment variable,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class PerfTimerImpl {
1717protected:
1818 long long CounterStart;
1919 double PCFreq;
20+ uint32_t GranularityPerSecond;
2021
2122public:
2223 PerfTimerImpl () : CounterStart(0 ), PCFreq(0.0 ) {};
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ ProfilePoint::~ProfilePoint() {
104104class PerfTimerWindows : public PerfTimerImpl {
105105
106106public:
107- PerfTimerWindows (){};
107+ PerfTimerWindows () {};
108108 virtual bool Init () override {
109109 LARGE_INTEGER li;
110110 if (QueryPerformanceCounter (&li))
@@ -120,7 +120,7 @@ class PerfTimerWindows : public PerfTimerImpl {
120120 }
121121 // QueryPerformanceFrequency returns counts per second
122122 // If we need milliseconds we divide by 10^3
123- uint32_t GranularityPerSecond = env::getGranularityUnitsPerSecond ();
123+ GranularityPerSecond = env::getGranularityUnitsPerSecond ();
124124 PCFreq = li.QuadPart / GranularityPerSecond;
125125 return true ;
126126 }
@@ -155,7 +155,7 @@ class PerfTimerPosix : public PerfTimerImpl {
155155 }
156156 // clock_getres returns counts per nanosecond
157157 // If we need milliseconds we multiply by 10^6
158- uint32_t GranularityPerSecond = env::getGranularityUnitsPerSecond ();
158+ GranularityPerSecond = env::getGranularityUnitsPerSecond ();
159159 PCFreq = (Res.tv_sec * 1e9 + Res.tv_nsec ) * (1e9 / GranularityPerSecond);
160160 return true ;
161161 }
You can’t perform that action at this time.
0 commit comments