Git Product home page Git Product logo

cxxfunctionbenchmark's Introduction

C++ Function Benchmark

Benchmark for various C++ function implementations. This project focuses on invocation time.

Currently include:

Sample Result

Compiled with MSVC (64-bit/Visual Studio 15.9.4/Release Build/Boost 1.69.0)

The size of each implementation is shown in the [size] section. Keep in mind that bigger size does not necessarily mean that it's less space efficient, it may due to the decision on how much space is reserved for small object optimization. Other sections show the timing of function invocation for each implementation when assigned different callable objects.

[size]
stdex::function<int(int)>: 24
std::function<int(int)>: 64
cxx_function::function<int(int)>: 40
multifunction<int(int)>: 32
boost::function<int(int)>: 40
func::function<int(int)>: 32
generic::delegate<int(int)>: 48
fu2::function<int(int)>: 32
fixed_size_function<int(int)>: 128
embxx_util_StaticFunction: 64
Function_: 56
inplace_function: 48
Delegate: 56

[function_pointer]
Perf< no_abstraction >: 0.1581233938 [s] {checksum: 0}
Perf< stdex::function<int(int)> >: 0.2369854883 [s] {checksum: 0}
Perf< std::function<int(int)> >: 0.2639573047 [s] {checksum: 0}
Perf< cxx_function::function<int(int)> >: 0.2635273223 [s] {checksum: 0}
Perf< multifunction<int(int)> >: 0.2633797704 [s] {checksum: 0}
Perf< boost::function<int(int)> >: 0.2632382534 [s] {checksum: 0}
Perf< func::function<int(int)> >: 0.2367664236 [s] {checksum: 0}
Perf< generic::delegate<int(int)> >: 0.2370002737 [s] {checksum: 0}
Perf< fu2::function<int(int)> >: 0.2363500196 [s] {checksum: 0}
Perf< fixed_size_function<int(int)> >: 0.2627183519 [s] {checksum: 0}
Perf< embxx_util_StaticFunction >: 0.2630701831 [s] {checksum: 0}
Perf< Function_ >:    0.2629322870 [s] {checksum: 0}
Perf< inplace_function >: 0.2364676990 [s] {checksum: 0}
Perf< Delegate >:     0.2101452315 [s] {checksum: 0}

[compile_time_function_pointer]
Perf< no_abstraction >: 0.0533959710 [s] {checksum: 0}
Perf< stdex::function<int(int)> >: 0.1576716859 [s] {checksum: 0}
Perf< std::function<int(int)> >: 0.1884306668 [s] {checksum: 0}
Perf< cxx_function::function<int(int)> >: 0.1845623337 [s] {checksum: 0}
Perf< multifunction<int(int)> >: 0.1847705357 [s] {checksum: 0}
Perf< boost::function<int(int)> >: 0.1844458613 [s] {checksum: 0}
Perf< func::function<int(int)> >: 0.1580304572 [s] {checksum: 0}
Perf< generic::delegate<int(int)> >: 0.1585376856 [s] {checksum: 0}
Perf< fu2::function<int(int)> >: 0.1911532853 [s] {checksum: 0}
Perf< fixed_size_function<int(int)> >: 0.1854126428 [s] {checksum: 0}
Perf< embxx_util_StaticFunction >: 0.1866678897 [s] {checksum: 0}
Perf< Function_ >:    0.2034746200 [s] {checksum: 0}
Perf< inplace_function >: 0.1583309923 [s] {checksum: 0}
Perf< Delegate >:     0.1323627700 [s] {checksum: 0}

[compile_time_delegate]
Perf< no_abstraction >: 0.0546856165 [s] {checksum: 0}
Perf< stdex::function<int(int)> >: 0.1580582175 [s] {checksum: 0}
Perf< std::function<int(int)> >: 0.1906249349 [s] {checksum: 0}
Perf< cxx_function::function<int(int)> >: 0.1849874883 [s] {checksum: 0}
Perf< multifunction<int(int)> >: 0.1854241090 [s] {checksum: 0}
Perf< boost::function<int(int)> >: 0.1845475484 [s] {checksum: 0}
Perf< func::function<int(int)> >: 0.1583859094 [s] {checksum: 0}
Perf< generic::delegate<int(int)> >: 0.1584073331 [s] {checksum: 0}
Perf< fu2::function<int(int)> >: 0.2108410486 [s] {checksum: 0}
Perf< fixed_size_function<int(int)> >: 0.1846688487 [s] {checksum: 0}
Perf< embxx_util_StaticFunction >: 0.1865227518 [s] {checksum: 0}
Perf< Function_ >:    0.1851751718 [s] {checksum: 0}
Perf< inplace_function >: 0.1593198010 [s] {checksum: 0}
Perf< Delegate >:     0.1395119443 [s] {checksum: 0}

[heavy_functor]
Perf< stdex::function<int(int)> >: 0.1579305806 [s] {checksum: 0}
Perf< std::function<int(int)> >: 0.1896611708 [s] {checksum: 0}
Perf< cxx_function::function<int(int)> >: 0.1585654459 [s] {checksum: 0}
Perf< multifunction<int(int)> >: 0.2108531183 [s] {checksum: 0}
Perf< boost::function<int(int)> >: 0.1583361219 [s] {checksum: 0}
Perf< func::function<int(int)> >: 0.1845744034 [s] {checksum: 0}
Perf< generic::delegate<int(int)> >: 0.1842995164 [s] {checksum: 0}
Perf< fu2::function<int(int)> >: 0.1584091435 [s] {checksum: 0}
Perf< fixed_size_function<int(int)> >: 0.2105242195 [s] {checksum: 0}
Perf< embxx_util_StaticFunction >: 0.1869382506 [s] {checksum: 0}
Perf< Function_ >:    0.2071549678 [s] {checksum: 0}
Perf< inplace_function >: 0.1854696721 [s] {checksum: 0}
Perf< Delegate >:     0.1586031636 [s] {checksum: 0}

[non_assignable]
Perf< stdex::function<int(int)> >: 0.1844521979 [s] {checksum: 0}
Perf< std::function<int(int)> >: 0.1860469046 [s] {checksum: 0}
Perf< cxx_function::function<int(int)> >: 0.1845928097 [s] {checksum: 0}
Perf< multifunction<int(int)> >: 0.2108033309 [s] {checksum: 0}
Perf< boost::function<int(int)> >: 0.2104690007 [s] {checksum: 0}
Perf< func::function<int(int)> >: 0.1583373289 [s] {checksum: 0}
Perf< generic::delegate<int(int)> >: 0.1647982296 [s] {checksum: 0}
Perf< fu2::function<int(int)> >: 0.2116792880 [s] {checksum: 0}
Perf< fixed_size_function<int(int)> >: 0.1589755133 [s] {checksum: 0}
Perf< embxx_util_StaticFunction >: 0.1867176772 [s] {checksum: 0}
Perf< Function_ >:    0.1863730877 [s] {checksum: 0}
Perf< inplace_function >: 0.1588889134 [s] {checksum: 0}
Perf< Delegate >:     0.1401612932 [s] {checksum: 0}

[lambda_capture]
Perf< stdex::function<int(int)> >: 0.1594558867 [s] {checksum: 0}
Perf< std::function<int(int)> >: 0.1756666764 [s] {checksum: 0}
Perf< cxx_function::function<int(int)> >: 0.1849205015 [s] {checksum: 0}
Perf< multifunction<int(int)> >: 0.2112505126 [s] {checksum: 0}
Perf< boost::function<int(int)> >: 0.1586876514 [s] {checksum: 0}
Perf< func::function<int(int)> >: 0.1578183326 [s] {checksum: 0}
Perf< generic::delegate<int(int)> >: 0.1855617034 [s] {checksum: 0}
Perf< fu2::function<int(int)> >: 0.2103977896 [s] {checksum: 0}
Perf< fixed_size_function<int(int)> >: 0.1852678066 [s] {checksum: 0}
Perf< embxx_util_StaticFunction >: 0.2107188431 [s] {checksum: 0}
Perf< Function_ >:    0.1974609010 [s] {checksum: 0}
Perf< inplace_function >: 0.1851042624 [s] {checksum: 0}
Perf< Delegate >:     0.1584510857 [s] {checksum: 0}

[stateless_lambda]
Perf< stdex::function<int(int)> >: 0.1588940430 [s] {checksum: 0}
Perf< std::function<int(int)> >: 0.1799158079 [s] {checksum: 0}
Perf< cxx_function::function<int(int)> >: 0.1848345050 [s] {checksum: 0}
Perf< multifunction<int(int)> >: 0.2104273603 [s] {checksum: 0}
Perf< boost::function<int(int)> >: 0.1843752537 [s] {checksum: 0}
Perf< func::function<int(int)> >: 0.1583047408 [s] {checksum: 0}
Perf< generic::delegate<int(int)> >: 0.1582446941 [s] {checksum: 0}
Perf< fu2::function<int(int)> >: 0.1841890788 [s] {checksum: 0}
Perf< fixed_size_function<int(int)> >: 0.1860281966 [s] {checksum: 0}
Perf< embxx_util_StaticFunction >: 0.1871841704 [s] {checksum: 0}
Perf< Function_ >:    0.2044821367 [s] {checksum: 0}
Perf< inplace_function >: 0.1845451344 [s] {checksum: 0}
Perf< Delegate >:     0.1324608361 [s] {checksum: 0}

This shows the timing of each multi-method technique.

Perf< no_abstraction >: 0.0390731812 [s] {checksum: 3}
Perf< stdex::function<Sig...> >: 0.4739417077 [s] {checksum: 3}
Perf< multifunction<Sig...> >: 0.7793043578 [s] {checksum: 3}
Perf< cxx_function::function<Sig...> >: 0.5055884136 [s] {checksum: 3}
Perf< fu2::function<Sig...> >: 0.4742775466 [s] {checksum: 3}
Perf< virtual_base& >: 0.5028338104 [s] {checksum: 3}

cxxfunctionbenchmark's People

Contributors

bdiamand avatar frankhb avatar jamboree avatar naios avatar pmed avatar potswa avatar user706 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cxxfunctionbenchmark's Issues

sizeof readings are strange

Since merging #17 and fixing the build, README.md says that cxx_function and Boost went from 32 bytes (4 pointers) to 40 bytes. I can't reproduce this. I wonder what is special about @jamboree's build environment?

This is sort-of a bug in the benchmark (Boost really should have ABI stability), but also I'm curious whether this unknown factor is one I can detect and tolerate.

Allocator support

Please add tests for allocators when supported, at least with the default allocators.

Moreover, polymorphic_allocator with pool resources can be used when available. See also here for a C++11-ready implementation.

Long-duration intervals are susceptible to thermal throttling

On my laptop, relative measurements between libraries on a benchmark may vary by several percent, and times generally increase as the CPU heats up. CPU speed varies from second to second at high load. Results might be more accurate on smaller machines if shorter timeslices are used for the benchmarks.

Presumably the posted results come from a well-cooled workstation, so this only affects DIY users.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.