Coder Social home page Coder Social logo

benchmarks's People

Contributors

attractivechaos 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

benchmarks's Issues

Welcome to 2020 :)

Summary

std::vector is very fast. It is almost making kvec.h obsolete. Although cl.exe optimization does influence the results greatly. As it should be expected. x64 release build results are:

C array_, preallocated: 0.397 sec
C array_, dynamic: 1.054 sec
C vector, dynamic(kv_a): 0.510 sec
C vector, dynamic(kv_push): 1.030 sec
C++ vector, preallocated: 0.453 sec
C++ vector, dynamic: 1.654 sec

cl.exe is not known as excellent C compiler so I tried with CLANG 9.0 coming pre packaged with Visual Studio 2019. These are the results :

C array_, preallocated: 0.000 sec
C array_, dynamic: 1.135 sec
C vector, dynamic(kv_a): 0.480 sec
C vector, dynamic(kv_push): 1.107 sec
C++ vector, preallocated: 0.737 sec
C++ vector, dynamic: 1.835 sec

C side is a bit more noticeably faster with CLANG.Machine is: Windows 10 pro, (old) i5, 8GB RAM, 60 GB SSD. I assume LINUX, Mac results might vary.

Minor changes

kvec_test.cc has one modernization needed. Instead of:

std::vector<int> array_ ) ;
array_.reserve(N);

it should be

std::vector<int> array_( size_t(N), int(0) ) ;
// array_.reserve(N);

I also renamed array to array_.
I am using

Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28612 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

Of course instead of std::vector "pre-allocated", one would use std::array, which would make things even faster. But in this program we would have instant stack overflow.

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.