func measureMemoryUsage()

in Sources/_TracingBenchmarkTools/DriverUtils.swift [486:511]


    func measureMemoryUsage() -> Int? {
        #if os(Linux)
        return nil
        #else
        guard c.logMemory else { return nil }
        let current = TestRunner.getResourceUtilization()
        let maxRSS = current.ru_maxrss - baseline.ru_maxrss
        #if canImport(Darwin)
        let pageSize = _SC_PAGESIZE
        #else
        let pageSize = Int32(_SC_PAGESIZE)
        #endif
        let pages = { maxRSS / sysconf(pageSize) }
        func deltaEquation(_ stat: KeyPath<rusage, Int>) -> String {
            let b = baseline[keyPath: stat], c = current[keyPath: stat]
            return "\(c) - \(b) = \(c - b)"
        }
        logVerbose(
            """
                MAX_RSS \(deltaEquation(\rusage.ru_maxrss)) (\(pages()) pages)
                ICS \(deltaEquation(\rusage.ru_nivcsw))
                VCS \(deltaEquation(\rusage.ru_nvcsw))
            """)
        return maxRSS
        #endif
    }