MCPcopy Create free account
hub / github.com/ElementsProject/elements / gatherStabilityInformation

Function gatherStabilityInformation

src/bench/nanobench.h:1945–1999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1943}
1944
1945void gatherStabilityInformation(std::vector<std::string>& warnings, std::vector<std::string>& recommendations) {
1946 warnings.clear();
1947 recommendations.clear();
1948
1949 bool recommendCheckFlags = false;
1950
1951# if defined(DEBUG)
1952 warnings.emplace_back("DEBUG defined");
1953 recommendCheckFlags = true;
1954# endif
1955
1956 bool recommendPyPerf = false;
1957# if defined(__linux__)
1958 auto nprocs = sysconf(_SC_NPROCESSORS_CONF);
1959 if (nprocs <= 0) {
1960 warnings.emplace_back("couldn't figure out number of processors - no governor, turbo check possible");
1961 } else {
1962
1963 // check frequency scaling
1964 for (long id = 0; id < nprocs; ++id) {
1965 auto idStr = detail::fmt::to_s(static_cast<uint64_t>(id));
1966 auto sysCpu = "/sys/devices/system/cpu/cpu" + idStr;
1967 auto minFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_min_freq");
1968 auto maxFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_max_freq");
1969 if (minFreq != maxFreq) {
1970 auto minMHz = static_cast<double>(minFreq) / 1000.0;
1971 auto maxMHz = static_cast<double>(maxFreq) / 1000.0;
1972 warnings.emplace_back("CPU frequency scaling enabled: CPU " + idStr + " between " +
1973 detail::fmt::Number(1, 1, minMHz).to_s() + " and " + detail::fmt::Number(1, 1, maxMHz).to_s() +
1974 " MHz");
1975 recommendPyPerf = true;
1976 break;
1977 }
1978 }
1979
1980 auto currentGovernor = parseFile<std::string>("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor");
1981 if ("performance" != currentGovernor) {
1982 warnings.emplace_back("CPU governor is '" + currentGovernor + "' but should be 'performance'");
1983 recommendPyPerf = true;
1984 }
1985
1986 if (0 == parseFile<int>("/sys/devices/system/cpu/intel_pstate/no_turbo")) {
1987 warnings.emplace_back("Turbo is enabled, CPU frequency will fluctuate");
1988 recommendPyPerf = true;
1989 }
1990 }
1991# endif
1992
1993 if (recommendCheckFlags) {
1994 recommendations.emplace_back("Make sure you compile for Release");
1995 }
1996 if (recommendPyPerf) {
1997 recommendations.emplace_back("Use 'pyperf system tune' before benchmarking. See https://github.com/psf/pyperf");
1998 }
1999}
2000
2001void printStabilityInformationOnce(std::ostream* outStream) {
2002 static bool shouldPrint = true;

Callers 1

Calls 5

to_sFunction · 0.85
NumberClass · 0.85
emplace_backMethod · 0.80
to_sMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected