Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1972

Performance of method ToHexString()

    • Fully Compatible
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      From several profiling sessions of my application I've noticed that method ToHexString() is used very often. DotTrace has also marked it as one of hot methods during profiling. I've found a solution which has about 40x speedup in compare with current implementation.
      Here's attached benchmarking info and code:

      BenchmarkDotNet=v0.10.5, OS=Windows 10.0.15063
      Processor=Intel Core i5-2400 CPU 3.10GHz (Sandy Bridge), ProcessorCount=4
      Frequency=3037251 Hz, Resolution=329.2451 ns, Timer=TSC
        [Host]     : Clr 4.0.30319.42000, 32bit LegacyJIT-v4.7.2046.0
        DefaultJob : Clr 4.0.30319.42000, 32bit LegacyJIT-v4.7.2046.0
      
      
                      Method |      Mean |     Error |    StdDev |
      ---------------------- |----------:|----------:|----------:|
       MongoDbImplementation | 97.146 us | 1.1451 us | 1.0711 us |
                   HandCoded |  1.932 us | 0.0216 us | 0.0202 us |
      

      Benchmark code: https://gist.github.com/ahydrax/477fedfe5a44bb49ff862b554694a4f1

            Assignee:
            damien.guard@mongodb.com Damien Guard
            Reporter:
            ahydrax Viktor Svyatokha
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: