String Scenarios

March 30, 2021 ยท View on GitHub

These benchmarks are designed to test specific aspects of the calculation, avoiding specific optimizations.

All benchmarks were run with the following configuration:

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18362.778 (1903/May2019Update/19H1)
Intel Core i7-6700HQ CPU 2.60GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=3.1.200
  [Host]     : .NET Core 3.0.1 (CoreCLR 4.700.19.51502, CoreFX 4.700.19.51609), X64 RyuJIT
  Job-AQLRZV : .NET Framework 4.8 (4.8.4150.0), X64 RyuJIT
  Job-IVETVG : .NET Core 3.0.1 (CoreCLR 4.700.19.51502, CoreFX 4.700.19.51609), X64 RyuJIT

Edge Difference Benchmark

This benchmark eliminates bonuses for trimming equal characters at the start and end. The strings the same length and, besides the edges, are only filled with matching characters. This then forces the fastest path internally (least operations) for calculating distance.

MethodJobRuntimeMeanErrorStdDevOp/sRatioSpeedupRatioSDCode SizeGen 0Gen 1Gen 2Allocated
BaselineJob-LYUZXD.NET 4.7.2247.07 us3.845 us3.408 us4,047.41.001.000.002559 B74.707018.5547-301049 B
QuickenshteinJob-LYUZXD.NET 4.7.229.03 us0.492 us0.460 us34,449.20.128.500.003705 B----
FastenshteinJob-LYUZXD.NET 4.7.293.08 us1.011 us0.896 us10,743.20.382.650.01324 B0.2441--1092 B
BaselineJob-MALOLQ.NET Core 5.0301.59 us4.449 us4.162 us3,315.81.220.820.032057 B66.894520.5078-291736 B
QuickenshteinJob-MALOLQ.NET Core 5.032.33 us0.557 us0.596 us30,930.80.137.640.004757 B----
FastenshteinJob-MALOLQ.NET Core 5.094.43 us0.798 us0.746 us10,589.50.382.620.01317 B0.2441--1088 B

Text Length Benchmark

This benchmark shows the impact of various, though relatively short, string lengths. The calculation is forced to compute the worst possible case due to no matching characters.

MethodJobRuntimeNumberOfCharactersMeanErrorStdDevOp/sRatioSpeedupRatioSDCode SizeGen 0Gen 1Gen 2Allocated
BaselineJob-LYUZXD.NET 4.7.25652.06 ns12.670 ns12.444 ns1,533,589.51.001.000.002559 B0.2241--706 B
QuickenshteinJob-LYUZXD.NET 4.7.25103.35 ns2.103 ns2.422 ns9,675,749.30.166.310.013705 B----
FastenshteinJob-LYUZXD.NET 4.7.2548.28 ns0.714 ns0.668 ns20,710,439.70.0713.490.00324 B0.0153--48 B
BaselineJob-MALOLQ.NET Core 5.05231.63 ns4.422 ns4.731 ns4,317,188.30.362.810.012057 B0.1707--536 B
QuickenshteinJob-MALOLQ.NET Core 5.05218.24 ns2.175 ns2.035 ns4,582,144.80.342.990.014757 B----
FastenshteinJob-MALOLQ.NET Core 5.0548.01 ns0.938 ns0.877 ns20,829,144.20.0713.570.00317 B0.0153--48 B
BaselineJob-LYUZXD.NET 4.7.2203,169.29 ns60.686 ns56.766 ns315,527.81.001.000.002559 B1.0567--3330 B
QuickenshteinJob-LYUZXD.NET 4.7.220669.12 ns12.200 ns11.412 ns1,494,508.20.214.740.013705 B----
FastenshteinJob-LYUZXD.NET 4.7.220563.85 ns10.762 ns9.540 ns1,773,506.20.185.620.00324 B0.0324--104 B
BaselineJob-MALOLQ.NET Core 5.0202,085.53 ns41.421 ns38.745 ns479,493.80.661.520.012057 B0.8659--2720 B
QuickenshteinJob-MALOLQ.NET Core 5.020871.95 ns15.622 ns14.613 ns1,146,850.30.283.640.014757 B----
FastenshteinJob-MALOLQ.NET Core 5.020557.58 ns10.901 ns10.706 ns1,793,477.50.185.680.00317 B0.0324--104 B
BaselineJob-LYUZXD.NET 4.7.2408,088.09 ns93.844 ns87.782 ns123,638.61.001.000.002559 B3.0365--9564 B
QuickenshteinJob-LYUZXD.NET 4.7.2402,431.94 ns46.144 ns43.163 ns411,194.70.303.330.013705 B----
FastenshteinJob-LYUZXD.NET 4.7.2402,387.54 ns44.385 ns41.518 ns418,840.80.303.390.01324 B0.0572--185 B
BaselineJob-MALOLQ.NET Core 5.0407,172.82 ns136.403 ns127.592 ns139,415.10.891.130.022057 B2.6779--8400 B
QuickenshteinJob-MALOLQ.NET Core 5.0402,042.65 ns30.383 ns28.420 ns489,559.90.253.960.014757 B----
FastenshteinJob-MALOLQ.NET Core 5.0402,494.32 ns49.260 ns48.379 ns400,911.40.313.240.01317 B0.0572--184 B

Huge Text Benchmark

This benchmark really pushes the calculator to the limit with extremely long string lengths. This is combined with the fact that this is a worst case run with no matching characters.

MethodJobRuntimeNumberOfCharactersMeanErrorStdDevOp/sRatioSpeedupRatioSDGen 0Gen 1Gen 2AllocatedCode Size
Quickenshtein_NoThreadingJob-LYUZXD.NET 4.7.2819282.33 ms1.479 ms1.383 ms12.14651.001.000.00----3705 B
Quickenshtein_NoThreadingJob-MALOLQ.NET Core 5.0819218.02 ms0.184 ms0.172 ms55.48770.224.570.01---9 B4925 B
Quickenshtein_WithThreadingJob-LYUZXD.NET 4.7.2819229.18 ms0.492 ms0.436 ms34.26441.001.000.00---1024 B5048 B
Quickenshtein_WithThreadingJob-MALOLQ.NET Core 5.0819218.53 ms0.258 ms0.241 ms53.96350.641.570.01---818 B10408 B
FastenshteinJob-LYUZXD.NET 4.7.2819284.62 ms1.636 ms1.680 ms11.81781.001.000.00---32816 B324 B
FastenshteinJob-MALOLQ.NET Core 5.0819284.46 ms1.330 ms1.244 ms11.84031.001.000.03---32999 B48 B
Quickenshtein_NoThreadingJob-LYUZXD.NET 4.7.2327681,293.23 ms22.708 ms21.241 ms0.77331.001.000.00----3705 B
Quickenshtein_NoThreadingJob-MALOLQ.NET Core 5.032768295.37 ms5.449 ms5.097 ms3.38550.234.380.01---144 B4925 B
Quickenshtein_WithThreadingJob-LYUZXD.NET 4.7.232768436.31 ms6.126 ms5.730 ms2.29201.001.000.00---8192 B5048 B
Quickenshtein_WithThreadingJob-MALOLQ.NET Core 5.032768286.32 ms3.283 ms2.741 ms3.49260.661.530.01---1768 B158 B
FastenshteinJob-LYUZXD.NET 4.7.2327681,346.64 ms22.841 ms21.366 ms0.74261.001.000.00---131096 B324 B
FastenshteinJob-MALOLQ.NET Core 5.0327681,354.35 ms21.269 ms19.895 ms0.73841.010.990.02---131096 B48 B

Edge Match Benchmark

This benchmark shows how well the calculator can optimise matching characters at the start and end.

MethodJobRuntimeNumberOfCharactersMeanErrorStdDevOp/sRatioSpeedupRatioSDGen 0Gen 1Gen 2AllocatedCode Size
QuickenshteinJob-LYUZXD.NET 4.7.240104.1 ns1.40 ns1.31 ns9,603,518.531.001.000.00----3705 B
QuickenshteinJob-MALOLQ.NET Core 5.040159.2 ns2.23 ns2.08 ns6,282,205.521.530.650.03----4757 B
FastenshteinJob-LYUZXD.NET 4.7.2401,991.4 ns34.20 ns31.99 ns502,156.111.001.000.000.0572--185 B324 B
FastenshteinJob-MALOLQ.NET Core 5.0401,437.9 ns26.20 ns24.51 ns695,439.330.721.390.020.0572--184 B317 B
QuickenshteinJob-LYUZXD.NET 4.7.281925,327.3 ns103.54 ns106.33 ns187,713.191.001.000.00----3705 B
QuickenshteinJob-MALOLQ.NET Core 5.08192852.8 ns23.53 ns66.38 ns1,172,647.930.156.720.02----4757 B
FastenshteinJob-LYUZXD.NET 4.7.2819265,273,509.2 ns772,466.84 ns722,565.96 ns15.321.001.000.00---32816 B324 B
FastenshteinJob-MALOLQ.NET Core 5.0819254,018,758.5 ns1,053,343.43 ns985,298.10 ns18.510.831.210.02---32792 B317 B

Empty Text Benchmark

This benchmark shows how well the calculator can optimise an empty string in either the source or target.

MethodJobRuntimeIsSourceEmptyMeanErrorStdDevOp/sRatioSpeedupRatioSDCode SizeGen 0Gen 1Gen 2Allocated
QuickenshteinJob-LYUZXD.NET 4.7.2False2.669 ns0.0702 ns0.0657 ns374,651,568.41.001.000.00199 B----
QuickenshteinJob-MALOLQ.NET Core 5.0False4.232 ns0.1143 ns0.1223 ns236,283,845.81.590.630.06254 B----
FastenshteinJob-LYUZXD.NET 4.7.2False2.190 ns0.0649 ns0.0575 ns456,581,987.11.001.000.00324 B----
FastenshteinJob-MALOLQ.NET Core 5.0False2.357 ns0.0596 ns0.0498 ns424,233,188.81.070.930.03317 B----
QuickenshteinJob-LYUZXD.NET 4.7.2True2.365 ns0.0363 ns0.0322 ns422,752,251.31.001.000.00199 B----
QuickenshteinJob-MALOLQ.NET Core 5.0True3.587 ns0.1037 ns0.1018 ns278,787,396.61.520.660.05254 B----
FastenshteinJob-LYUZXD.NET 4.7.2True300.852 ns6.0131 ns6.1751 ns3,323,894.61.001.000.00324 B0.5174--1629 B
FastenshteinJob-MALOLQ.NET Core 5.0True291.861 ns5.6623 ns5.8147 ns3,426,286.50.971.030.03317 B0.5174--1624 B