Git Product home page Git Product logo

exceptionsperformance's Introduction

ExceptionsPerformance

Benchmarking of using exceptions to control code flow. There are two ways to get the value from list of strings (in this solution), one is searching for string using loop and another is using exceptions to tell code that value is not found. These ways are created to simulate behaviour of ADO .NET DataReader class, where are two ways to get whether data row contains field or not. They are:

  • GetOrdinal - getting index by field name. Throws exception when field not found.
  • Loop with GetFieldName. No exceptions are thrown.

Start Benchmarker project from your IDE and look at results. These are results from my laptop:

                           Method |            Mean |        StdErr |         StdDev | Rank |
--------------------------------- |---------------- |-------------- |--------------- |----- |
      WithLoop_100PercentNotFound |   5,301.9258 ns |    53.0328 ns |    339.5758 ns |    4 |
       WithLoop_50PercentNotFound |   6,160.5118 ns |    72.6483 ns |    355.9023 ns |    5 |
       WithLoop_10PercentNotFound |   4,097.5560 ns |    40.5199 ns |    249.7812 ns |    3 |
                WithLoop_AllFound |   3,048.1326 ns |    30.3764 ns |    163.5820 ns |    2 |
 WithException_100PercentNotFound | 157,972.4183 ns | 1,694.8235 ns | 11,619.1246 ns |    8 |
  WithException_50PercentNotFound |  78,544.0070 ns |   784.2743 ns |  5,319.2074 ns |    7 |
  WithException_10PercentNotFound |  15,873.0764 ns |   122.1438 ns |    440.3958 ns |    6 |
           WithException_AllFound |     530.6526 ns |     6.0316 ns |     25.5897 ns |    1 |

exceptionsperformance's People

Contributors

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