Skip to content

Investigate perf gain by using the .NET char comparison pattern #1915

Open

Description

Description of the new feature/enhancement

This is a follow-up issue tracking the discussion in #1909 (comment).
We can investigate to see if we can get some perf gain by using the .NET char comparison pattern, such as in https://source.dot.net/#System.Private.CoreLib/UnicodeUtility.cs,141

Activity

  1. ghost added
    Needs-Triage 🔍It's a new issue that core contributor team needs to triage.
    on Oct 30, 2020
  2. iSazonov commented on Oct 30, 2020

    @iSazonov

    Do you want to measure only LengthInBufferCells() method?
    I could measure and share results if you want.

  3. daxian-dbw commented on Oct 30, 2020

    @daxian-dbw
    MemberAuthor

    Yup, measuring only the LengthInBufferCells() would be enough. Thanks!

  4. iSazonov commented on Oct 31, 2020

    @iSazonov

    In my test the worst case (char is in last range) is improved up to 16%. Thoughts?

    BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18362.1082 (1903/May2019Update/19H1)
    Intel Core i5-2410M CPU 2.30GHz (Sandy Bridge), 1 CPU, 4 logical and 2 physical cores
    .NET Core SDK=5.0.100-rc.2.20479.15
      [Host]     : .NET Core 5.0.0 (CoreCLR 5.0.20.47505, CoreFX 5.0.20.47505), X64 RyuJIT
      DefaultJob : .NET Core 5.0.0 (CoreCLR 5.0.20.47505, CoreFX 5.0.20.47505), X64 RyuJIT
    
    
    Method InputString Mean Error StdDev Ratio Gen 0 Gen 1 Gen 2 Allocated Code Size
    LengthOrig ï¿¡ 8.059 ns 0.0812 ns 0.0759 ns 1.00 - - - - 251 B
    LengthNew ï¿¡ 6.757 ns 0.0846 ns 0.0791 ns 0.84 - - - - 206 B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions