Gathering benchmarks for Excel add-ins. Inspired by The Benchmarks Game and some LinkedIn posts.
- Python via xlOil - thanks for the help @cunnane!
- Python via xlwings
- C# via Excel-DNA - thanks for the help @govert!
- C++ via xlladdins - credits to @keithalewis!
- VBA
- Native Excel Formulas
Unfortunately I couldn't make a JavaScript addin to work. Suggestions welcome!
Time in miliseconds:
Name | Excel SUM(...) | C++ (xlladdins) |
C# (Excel-DNA) |
Python + Numpy (xlOil) |
Python + Numba (xlOil) |
Python Only (xlOil) |
VBA | Python + Numpy (xlwings) |
---|---|---|---|---|---|---|---|---|
Median | 3.2 | 10.1 | 13.1 | 36.7 | 38.6 | 117.9 | 239.5 | 893.5 |
I used the VBA code provided by Microsoft for performance measurement, in order to calculate the runtime of each cell with formulas. I changed it to run a 100 times in order to compute the statistics.
- Download Visual Studio Community 2022 (free for personal use)
- Install with .NET and C++ support
- Install Python 3.10 (pyenv is a nice way to control versions)
- Run the following commands in a terminal:
pip install xloil xlwings numba icc-rt cffi --upgrade
xlwings addin install
xloil install
- Clone the repo. On the instructions below,
ROOT
will be the repo folder path. - Python - xlOil (has to be done before opening the workbook):
- Open
%APPDATA%\xlOil\xlOil.ini
. - On the parameter
PYTHONPATH
, add;ROOT\Python
to the end - Change parameter:
LoadModules=["xloil_addin"]
- Open
- Open
ROOT\Benchmarks.xlsm
- C#:
- Build CSharpAddin project with Release configuration.
- Drag this file to Excel:
ROOT\CSharp\bin\Release\net6.0-windows\CSharpAddin64.xll
- C++:
- Build CppAddin project with Release configuration.
- Drag this file to Excel:
ROOT\Cpp\x64\Release\CppAddin.xll
- Python - xlwings:
- On the xlwings tab inside Excel, add
ROOT\Python
toPYTHONPATH
- On
UDF Modules parameter
, writexlwings_addin
- Click
Import Functions
- On the xlwings tab inside Excel, add
- Make sure the formulas for each framework work (yellow cells).
- Click the button Run to compute the times