MCPcopy Create free account
hub / github.com/apple/foundationdb / getMachineLoad

Function getMachineLoad

flow/Platform.actor.cpp:758–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

756}
757
758void getMachineLoad(uint64_t& idleTime, uint64_t& totalTime, bool logDetails) {
759 INJECT_FAULT(platform_error,
760 "getMachineLoad"); // getMachineLoad: Even though this function doesn't throw errors, the equivalents
761 // for other platforms do, and since all of our simulation testing is on Linux...
762 std::ifstream stat_stream("/proc/stat", std::ifstream::in);
763
764 std::string ignore;
765 stat_stream >> ignore;
766
767 uint64_t t_user, t_nice, t_system, t_idle, t_iowait, t_irq, t_softirq, t_steal, t_guest;
768 stat_stream >> t_user >> t_nice >> t_system >> t_idle >> t_iowait >> t_irq >> t_softirq >> t_steal >> t_guest;
769
770 totalTime = t_user + t_nice + t_system + t_idle + t_iowait + t_irq + t_softirq + t_steal + t_guest;
771 idleTime = t_idle + t_iowait;
772
773 if (!DEBUG_DETERMINISM && logDetails)
774 TraceEvent("MachineLoadDetail")
775 .detail("User", t_user)
776 .detail("Nice", t_nice)
777 .detail("System", t_system)
778 .detail("Idle", t_idle)
779 .detail("IOWait", t_iowait)
780 .detail("IRQ", t_irq)
781 .detail("SoftIRQ", t_softirq)
782 .detail("Steal", t_steal)
783 .detail("Guest", t_guest);
784}
785
786void getDiskStatistics(std::string const& directory,
787 uint64_t& currentIOs,

Callers 1

getSystemStatisticsFunction · 0.85

Calls 2

TraceEventClass · 0.85
detailMethod · 0.80

Tested by

no test coverage detected