// Returns a human-readable size string such as "1MB".
std::string PrettySize(uint64_t size_in_bytes);
// Splits a string using the given separator character into a vector of // strings. Empty strings will be omitted. template<typename StrIn, typename Str> void Split(const StrIn& s, char separator, std::vector<Str>* out_result);
// Returns the calling thread's tid. (The C libraries don't expose this.)
uint32_t GetTid();
// Returns the given thread's name.
std::string GetThreadName(pid_t tid);
// Sets the pthread name of the current thread. The name may be truncated to an // implementation-defined limit. void SetThreadName(constchar* thread_name);
// Sets the pthread name of the given thread. The name may be truncated to an // implementation-defined limit. Does nothing if not supported by the OS. void SetThreadName(pthread_t thr, constchar* thread_name);
// Reads data from "/proc/self/task/${tid}/stat". void GetTaskStats(pid_t tid, char* state, int* utime, int* stime, int* task_cpu);
class VoidFunctor { public: template <typename A> inlinevoidoperator()([[maybe_unused]] A a) const {}
template <typename A, typename B> inlinevoidoperator()([[maybe_unused]] A a, [[maybe_unused]] B b) const {}
template <typename A, typename B, typename C> inlinevoidoperator()([[maybe_unused]] A a, [[maybe_unused]] B b, [[maybe_unused]] C c) const {}
};
staticinlineconstvoid* EntryPointToCodePointer(constvoid* entry_point) {
uintptr_t code = reinterpret_cast<uintptr_t>(entry_point); // TODO: Make this Thumb2 specific. It is benign on other architectures as code is always at // least 2 byte aligned.
code &= ~0x1; returnreinterpret_cast<constvoid*>(code);
}
// Forces the compiler to emit a load instruction, but discards the value. // Useful when dealing with memory paging. template <typename T> inlinevoid ForceRead(const T* pointer) { static_cast<void>(*const_cast<volatile T*>(pointer));
}
// Lookup value for a given key in /proc/self/status. Keys and values are separated by a ':' in // the status file. Returns value found on success and "<unknown>" if the key is not found or // there is an I/O error.
std::string GetProcessStatus(constchar* key);
// Copy a prefix of /proc/pid/task/tid/stat of the given length into buf. Return the number of // bytes actually read, 0 on error.
size_t GetOsThreadStat(pid_t tid, char* buf, size_t len);
// Return a short prefix of /proc/pid/task/tid/stat as quickly and robustly as possible. Used for // debugging timing issues and possibly issues with /proc itself. Always atomic.
std::string GetOsThreadStatQuick(pid_t tid);
// Given a /proc/.../stat string or prefix, such as those returned by the above, return the single // character representation of the thread state from that string, or '?' if it can't be found. char GetStateFromStatString(const std::string& stat_output);
// Return a concatenation of the output of GetOsThreadStatQuick(tid) for all other tids. // Less robust against concurrent change, but individual stat strings should still always // be consistent. Called only when we are nearly certain to crash anyway.
std::string GetOtherThreadOsStats();
// Retrieve the first 3 fields of each of the sum and full lines in /proc/pressure/io, and // combine them into a string. Returns an empty string if something goes wrong, including the // common case in which we don't have permission to read /proc/pressure/io.
std::string GetOSPressureIOSummary();
// Retrieve the first line from /proc/diskstats whose device name starts with disk_name, and copy // the result, except for major and minor device number, into buf. If the fields in the result are // numbered starting with 0, reulting field numbers match those in the kernel iostats.rst file. // Return the number of characters in the resulting buffer. // Note: Likely to fail and return 0 for normal unprivileged Android processes.
size_t GetOSDiskStats(constchar* disk_name, char* buf, size_t len);
// Encapulates the /proc/diskstats fields we currently consider the most interesting: // See iostats.rst for field descriptions. // Field 8: milliseconds spent writing. // Field 10: milliseconds spent doing IO. // Field 17: milliseconds spent flushing. // Field 9: IOs in progress. // // Note that the first 3 really require two observations to be meaningful. // We assign only those values we actually find. // // These fields are written by the kernel as unsigned int's, and could theoretically wrap. struct ConciseDiskStats { unsignedint write_millis_; unsignedint io_millis_; unsignedint flush_millis_; unsignedint in_progress_;
// Construct ConciseDiskStats representing the current statistics for disk_name. // If this fails. e.g. because /proc/diskstats is not readable (likely on Android), then all // fields are zero. It's possible flush_millis_ is not supported, and will always be zero, even // if the other fields are nonzero. If disk_name is nullptr, leave all fields zeroed. explicit ConciseDiskStats(constchar* disk_name);
// Return a string representing the evolution of 'this' from 'earlier'. These should correspond // to the same disk. This is arguably the only meaningful way to print results. // Returns an empty string if the information is unavailable.
std::string SummarizeDiff(ConciseDiskStats earlier);
bool IsEmpty() { return io_millis_ == 0; }
};
} // namespace art
#endif// ART_LIBARTBASE_BASE_UTILS_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.