Git Product home page Git Product logo

sync_test's Introduction

sync_test Throwaway code. Looking at the time difference between

several common synchronization mechanisms for a million iterations of a producer/consumer loop.

The three mechanisms tried are:

  • A pipe. Producer writes a byte after each element is produced. Consumer reads a byte before consuming element.

  • A pthread_cond_t condition variable.

  • A sem_t couting semaphore.

The output on my machine (manjaro linux) is:

 evaitl@bb sync_test]$ ls
 LICENSE  Makefile  README.md  sync.c
 [evaitl@bb sync_test]$ make
 gcc -Wall -O2 -c -o sync.o sync.c
 gcc -Wall -O2 -o sync sync.o -lpthread
 [evaitl@bb sync_test]$ ./sync 
 Pipe. Q = 0, max_q_size 5956, underflows 0
 Time: 0 S:695100442 nS
 Cond var. Q = 0, max_q_size 104162, underflows 0
 Time: 0 S:465343564 nS
 Counting sem. Q = 0, max_q_size 19323, underflows 0
 Time: 0 S:430964583 nS
 [evaitl@bb sync_test]$ ./sync 
 Pipe. Q = 0, max_q_size 5299, underflows 0
 Time: 0 S:739420086 nS
 Cond var. Q = 0, max_q_size 89481, underflows 0
 Time: 0 S:423448141 nS
 Counting sem. Q = 0, max_q_size 2531, underflows 0
 Time: 0 S:418388530 nS
 [evaitl@bb sync_test]$ ./sync 
 Pipe. Q = 0, max_q_size 7543, underflows 0
 Time: 0 S:694078542 nS
 Cond var. Q = 0, max_q_size 334265, underflows 0
 Time: 0 S:398508465 nS
 Counting sem. Q = 0, max_q_size 56804, underflows 0
 Time: 0 S:381196771 nS

sync_test's People

Contributors

evaitl avatar

Watchers

James Cloos 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.