Coder Social home page Coder Social logo

ezbench's Introduction

EzBench ๐Ÿ

Easy-to-use single file header only performance comparator for C++ (cpp11 or later)

Usage

Include ezbench.hpp

include "ezbench.hpp"

Create a set of minimal functions to compare

void vecAdd(std::vector<TestStruct>& vec, uint32_t add_count)
{
    for (int i(add_count); i--;)
    {
        vec->push_back(TestStruct());
    }
}

Using a very simple test structure

struct TestStruct
{
    double useless[20];
    TestStruct() = default;
};

Build the benchmark - so EZ ๐Ÿ‘Œ

std::vector<TestStruct> vec;
std::list<TestStruct>   list;

uint8_t  iteration_count = 1;
uint32_t objects_count   = 1000000;

ezb::Benchmark bench{
    iteration_count, // Not implemented yet, set it to 1
    {
      {"Insertion", // Test 1
          {
            {"Vector", std::bind(vecAdd, vec,  objects_count)},
            {"List", std::bind(listAdd,  list, objects_count)}
          }
      },
      {"Iteration", // Test 2
          {
              {"Vector", std::bind(vecIter, vec)},
              {"List", std::bind(listIter,  list)}
          }
      },
      {"Deletion", // Test 3
          {
              {"Vector", std::bind(vecDel, vec)},
              {"List", std::bind(listDel,  list)}
          }
      }
  }
};

Output

-----[ Insertion ]-----
List    196.335 ms (100 % -> x1)
Vector  401.454 ms (204 % -> x2)

-----[ Iteration ]-----
Vector  11.769 ms (100 % -> x1)
List    63.3059 ms (537 % -> x5)

-----[ Deletion ]-----
List    63.6138 ms (100 % -> x1)
Vector  1355.97 ms (2131 % -> x21)

Future work โ˜•

  • Add metric configuration (only ms for now)
  • Implement multi iterations support with stats

ezbench's People

Contributors

johnbuffer avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.