1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:17:34 +00:00

LibELF: Skip DynamicObject::dump() if logging isn't enabled

I noticed that we were populating this StringBuilder and then throwing
away the result while profiling `true` with UserSpace emulator.

Before:

    courage:~ $ time -n 1000 true
    Timing report: 3454 ms
    ==============
    Command:         true
    Average time:    3.45 ms (median: 3, stddev: 3.42, min: 0, max:11)
    Excluding first: 3.45 ms (median: 3, stddev: 3.42, min: 0, max:11)

After:

    courage:~ $ time -n 1000 true
    Timing report: 3308 ms
    ==============
    Command:         true
    Average time:    3.30 ms (median: 3, stddev: 3.28, min: 0, max:12)
    Excluding first: 3.30 ms (median: 3, stddev: 3.29, min: 0, max:12)
This commit is contained in:
Brian Gianforcaro 2022-03-31 00:07:06 -07:00 committed by Andreas Kling
parent 1577bac6a5
commit 39f924a731

View file

@ -39,6 +39,7 @@ DynamicObject::~DynamicObject()
void DynamicObject::dump() const
{
if constexpr (DYNAMIC_LOAD_DEBUG) {
StringBuilder builder;
builder.append("\nd_tag tag_name value\n");
size_t num_dynamic_sections = 0;
@ -56,8 +57,9 @@ void DynamicObject::dump() const
if (m_has_runpath)
builder.appendff("DT_RUNPATH: {}\n", runpath());
dbgln_if(DYNAMIC_LOAD_DEBUG, "Dynamic section at address {} contains {} entries:", m_dynamic_address.as_ptr(), num_dynamic_sections);
dbgln_if(DYNAMIC_LOAD_DEBUG, "{}", builder.string_view());
dbgln("Dynamic section at address {} contains {} entries:", m_dynamic_address.as_ptr(), num_dynamic_sections);
dbgln("{}", builder.string_view());
}
}
void DynamicObject::parse()