Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create benchmark for [[likely]] performance #96

Open
uselessgoddess opened this issue Aug 11, 2021 · 1 comment · May be fixed by #91
Open

Create benchmark for [[likely]] performance #96

uselessgoddess opened this issue Aug 11, 2021 · 1 comment · May be fixed by #91
Labels
performance This can be done faster

Comments

@uselessgoddess
Copy link
Member

See the new attribute [[likely]]

compare (see this link)

        if (n <= MaximumFactorialNumber)
        {
            return Internal::_factorials[n];
        }
        else
        {
            throw std::out_of_range(std::string("Only numbers from 0 to ").append(std::to_string(MaximumFactorialNumber)).append("are supported by unsigned integer with 64 bits length."));
        }

And

        if (n <= MaximumFactorialNumber) [[likely]]
        {
            return Internal::_factorials[n];
        }
        else [[unlikely]]
        {
            throw std::out_of_range(std::string("Only numbers from 0 to ").append(std::to_string(MaximumFactorialNumber)).append("are supported by unsigned integer with 64 bits length."));
        }
@uselessgoddess uselessgoddess added the performance This can be done faster label Aug 11, 2021
@uselessgoddess
Copy link
Member Author

uselessgoddess commented Aug 12, 2021

See this example from godbolt

@uselessgoddess uselessgoddess linked a pull request Aug 12, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance This can be done faster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant