Git Product home page Git Product logo

truth-match-test's Introduction

truth-match-test

Test and benchmarking inspired by https://stackoverflow.com/questions/63003802/whats-the-fastest-way-to-interpret-a-bool-string-into-a-number-in-c/

A user named wovano challenged me just by posting graphs. Actual data! I decided to take this to the next level by implementing all of the code in question with Google Test and Benchmark.

A summary of results so far:

On a Ryzen 3900X:

------------------------------------------------------------
Benchmark                  Time             CPU   Iterations
------------------------------------------------------------
BM_zlynx1_tobool        15.6 ns         15.6 ns     34940037
BM_zlynx2_tobool        30.1 ns         30.1 ns     23208760
BM_wovano1_tobool       14.7 ns         14.7 ns     47891667
BM_wovano2_tobool       20.0 ns         20.0 ns     34996469
BM_chux1_tobool         31.5 ns         31.5 ns     21909135
BM_chux2_tobool         25.3 ns         25.3 ns     27068521
BM_user1_tobool         14.1 ns         14.1 ns     49916508
BM_user2_tobool         44.4 ns         44.4 ns     15614261

The test results are too noisy so I will summarize. The implementations here that do less, run faster in general.

I wrote the tests so that they should handle "true", "false", "True", "False", "1", "0", "" and a 500 byte string. The only implementations that pass are wovano2, zlynx2 (that's mine, I fixed it to pass!) and user (user is short for an anonymous user).

truth-match-test's People

Contributors

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