Giter Site home page Giter Site logo

sample's Introduction

Sample Code

Author

Scott Bailey

Why this code?

This bit of code I have hanging around that has some real world utility. I've used something like it to accumulate inbound data from various interfaces many times over the years.

In usage, our application might consume serial, TCP, or other streamed data. This accumulator allows us to easily peek at the data using iterators or the array operator as though it were a contiguous memory block. We might do this to search for unique header indicators or test checksums. We can then pop the bytes out of the accumulator and use or discard them as determined by prior tests.

CMake

CMake is useful. It's a solid choice for ensuring source can build just about anywhere. And CPM makes dependency managmenent simple and repeatable.

Benchmark

You can't tell if something is efficient without benchmarking. Google's benchmark seems pretty good for this purpose.

Boost

Boost is a great place to find libraries you might want to use but don't yet exist in the standard library. In this example, we look at the performance of std::deque, boost::container::devector, and boost::circular_buffer_space_optimized as internal containers for accumulator.

Spoiler: on my system, deque executes in about 6% more time than devector for this toy benchmark. And circular_buffer_space_optimized yielded 20% more time cost than deque! An implementation that also supported std::vector as the internal container might provide an intersting comparison as well.

Build and Test

This is one option. It works in Linux.

mkdir Build \
 && cd Build \
 && cmake .. -DCMAKE_BUILD_TYPE=Release \
 && cmake --build . \
 && ctest

For Windows, you might do the following in a gitbash window:

mkdir Build
cd Build
cmake ..
cmake --build .
ctest -C Debug

sample's People

Contributors

scottbailey avatar

Watchers

 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.