-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Performance of creating new cells #521
Comments
For performance, I did some benchmarks and with 1000 cells the reflection solution is 10 times faster, with 10000 cells it is more than 100 times faster |
Do you have a workable version on your box? We do accept PR. |
If Is this approach OK, also from a license perspective? If so, I might find some time to create a PR. |
Thank you for the tip. I will test if it has any side effect on existing logic. |
When creating an excel sheet with millions of cells and thousands of cells per row I noticed in the profiler that the majority of time is spent in a small function inside NPOI: XSSFRow.LastCellNum
Given that a SortedDictionary is used, it should be possible to find the last key in O(log(n)) time instead of O(n)
Unfortunately the available implementation of SortedDictionary doesn't have Min, Max even though the underlying SortedSet does.. but it would be possible to either roll your own which could exposes Min/Max
or more hacky but easy, access it with reflection..
In constructor of XSSFRow:
this._set = typeof(SortedDictionary<int, ICell>).GetField("_set", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this._cells) as SortedSet<KeyValuePair<int,ICell>>;
Then In GetFirstKey/GetLastKey use _set.Max.Key or _set.Min.Key
The text was updated successfully, but these errors were encountered: