Skip to content

std::set<std::string>::count() is more expensive with libc++ #66577

@firewave

Description

@firewave
#include <set>
#include <string>

int f(const std::set<std::string>& s)
{
    return s.count("s");
}

libstdc++

Iterations:        100
Instructions:      8100
Total Cycles:      6970
Total uOps:        9700

Dispatch Width:    4
uOps Per Cycle:    1.39
IPC:               1.16
Block RThroughput: 24.3

libc++

Iterations:        100
Instructions:      9500
Total Cycles:      8868
Total uOps:        12300

Dispatch Width:    4
uOps Per Cycle:    1.39
IPC:               1.07
Block RThroughput: 30.8

https://godbolt.org/z/WbGETxbqs

If you use a different type like int then libc++ is actually faster: https://godbolt.org/z/b9KKnrTjP

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions