Giter VIP home page Giter VIP logo

yes's Introduction

Random yes experiments

License: MIT

A series of implementations of the simplest form of yes, outputting an endless loop of y\n.

Inspired by, and C solutions based on, this Reddit post.

hsbyte based on this Reddit comment.

Usage

To compile, simply run :

make

To run a specific test, run :

./speedtest.sh [test]

To see the list of compiled tests, just run :

./speedtest.sh

To test GNU yes, or the yes installed on your system, run :

yes | pv > /dev/null

Results

These results are completely not rigorous. Each test was only run once for a total of 5 seconds each, which I believe was sufficient enough to see the improvements in each.

The percentages for each speed is of the speed of the intial test of GNU yes.

GNU yes

yes

5.53 GiB/s

Bash scripts

sh.sh (echo "y")

593 KiB/s (0.01%)—There is a lot of overhead from each call to echo.

shunroll.sh (echo "y\ny\ny\n...")

40.1 MiB/s (0.71%)—Less overhead due to less calls to echo, since each call prints multiple lines of y\n.

Haskell (ghc)

hs

12.3 MiB/s (0.21%)

hslist (infinite list)

9.07 MiB/s (0.16%)—Overhead of list usage.

hsbuf (manual flush every 8192)

196 MiB/s (3.46%)—Vast improvements from manually flushing and disabling flushing upon every newline.

hsbyte (use ByteString.Char 8)

4.08 GiB/s (73.78%)—Extreme improvements from using ByteString instead (based on this Reddit comment).

C (gcc -O3 -g)

c (printf)

138 MiB/s (2.44%)

cputs (puts)

203 MiB/s (3.58%)—Savings from not doing unnecessary formatting.

cbuf (write with buffer size 8192)

5.51 GiB/s (99.64%)—Extreme improvements from taking a leaf out of GNU yes's book—we write directly using buffer size of 8192.

Prerequisites

  • bash
  • ghc
  • gcc
  • make
  • pv
  • yes (maybe)

yes's People

Contributors

chuahou 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.