These benchmarks measure the build overhead (compilation time, memory usage, object size) introduced by the use of different implementations of the INVOKE abstraction.

function (see Source Code)

template <int I>
int fun(...) { return I; }
Case Pattern
plain call (&fun<I>)(1, 2, 3)
std::invoke std::invoke(&fun<I>, 1, 2, 3)
eggs::invoke eggs::invoke(&fun<I>, 1, 2, 3)
EGGS_INVOKE EGGS_INVOKE(&fun<I>, 1, 2, 3)

member_object (see Source Code)

template <int I>
struct mem
{
    int obj;
};
Case Pattern
plain call mem<I>{}.*(&mem<I>::obj)
std::invoke std::invoke(&mem<I>::obj, mem<I>{})
eggs::invoke eggs::invoke(&mem<I>::obj, mem<I>{})
EGGS_INVOKE EGGS_INVOKE(&mem<I>::obj, mem<I>{})

member_function (see Source Code)

template <int I>
struct mem
{
    int fun(...) { return I; };
};
Case Pattern
plain call (mem<I>{}.*(&mem<I>::fun))(1, 2, 3)
std::invoke std::invoke(&mem<I>::fun, mem<I>{}, 1, 2, 3)
eggs::invoke eggs::invoke(&mem<I>::fun, mem<I>{}, 1, 2, 3)
EGGS_INVOKE EGGS_INVOKE(&mem<I>::fun, mem<I>{}, 1, 2, 3)

callable (see Source Code)

template <int I>
struct callable {
    template <typename ...Args>
    auto operator()(Args&&... args) const
        noexcept(noexcept(fun<I>(std::forward<Args>(args)...)))
     -> decltype(fun<I>(std::forward<Args>(args)...))
    {
        return fun<I>(std::forward<Args>(args)...);
    }
};
Case Pattern
plain call callable<I>{}(1, 2, 3)
std::invoke std::invoke(callable<I>{}, 1, 2, 3)
eggs::invoke eggs::invoke(callable<I>{}, 1, 2, 3)
EGGS_INVOKE EGGS_INVOKE(callable<I>{}, 1, 2, 3)

Each pattern is instantiated for different values of I, and aspects of the build are captured: compilation time, memory usage, object size. Results for each benchmark are provided both as absolute values, as well as relative values based on the plain call case.

These benchmarks do NOT look at runtime performance. INVOKE is a zero-cost abstraction: no runtime overhead is introduced by its use in an optimized build.

Results


    Copyright Agustín Bergé, Fusion Fenix 2017-2020

    Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)