Created
October 5, 2024 18:01
-
-
Save jahav/6882efc19aae8f54f2f82333c95509d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SumProductBenchmark : IDisposable | |
{ | |
private readonly XLWorkbook _wb; | |
private readonly IXLWorksheet _ws; | |
[Params(1000, 10000, 100000)] | |
public int RowsCount; | |
public SumProductBenchmark() | |
{ | |
_wb = new XLWorkbook(); | |
_ws = _wb.AddWorksheet(); | |
} | |
[GlobalSetup] | |
public void Setup() | |
{ | |
_ws.Cell("A1").InsertData(Enumerable.Range(1, RowsCount)); | |
_ws.Cell("B1").InsertData(Enumerable.Range(1, RowsCount).Reverse()); | |
_ws.Cell("C1").InsertData(Enumerable.Range(1, RowsCount)); | |
_ws.Cell("D1").InsertData(Enumerable.Range(1, RowsCount).Reverse()); | |
} | |
[Benchmark] | |
public XLCellValue SumProduct() => _ws.Evaluate($"SUMPRODUCT(A1:B{RowsCount}, C1:D{RowsCount})"); | |
[Benchmark] | |
public XLCellValue LegacySumProduct() => _ws.Evaluate($"SUMPRODUCT.LEGACY(A1:B{RowsCount}, C1:D{RowsCount})"); | |
public void Dispose() => _wb.Dispose(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment