You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The dedupl operation in SetCellRichText() is quite CPU intensive when exporting a bunch of cells together (at least O(n²s), where n is the number of cells and s is the size of rich text in each cell):
The CPU usage should be comparable to SetCellStr(), SetCellDefault() etc.
Possible solutions:
Provide an option to switch off the reflect.DeepEqual() comparisons, or
Marshal the rich text structure to utilize a hash map or bloom filter instead of brute-force loops to reduce the time complexity to O(n·s). This is my suggested approach, but the process of serialization and hashing the (possibly large) serialized result would both introduce some noticeable overheads.
Get rid of SetCellRichText() and stick to the good old SetCellStr() instead where performance matters. In my own case I only need correct line breaks (Preserve whitespace in cells #976) and do not need fancy rich text.
Description
The dedupl operation in
SetCellRichText()
is quite CPU intensive when exporting a bunch of cells together (at least O(n²s), where n is the number of cells and s is the size of rich text in each cell):Steps to reproduce the issue:
Set a number of cells with
SetCellRichText()
.Describe the results you received:
The
reflect.DeepEqual()
loop caused high CPU usage. Please see the pprof result for details.Describe the results you expected:
The CPU usage should be comparable to
SetCellStr()
,SetCellDefault()
etc.Possible solutions:
reflect.DeepEqual()
comparisons, orSetCellRichText()
and stick to the good oldSetCellStr()
instead where performance matters. In my own case I only need correct line breaks (Preserve whitespace in cells #976) and do not need fancy rich text.Output of
go version
:Excelize version or commit ID:
v2.4.0 (d42834f)
The text was updated successfully, but these errors were encountered: