Bug 54137 - PATCH Patch for performance issues with DataFormatter Fractions
Summary: PATCH Patch for performance issues with DataFormatter Fractions
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.9-dev
Hardware: PC All
: P2 normal with 2 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-12 11:34 UTC by Alan Davis
Modified: 2012-11-16 09:46 UTC (History)
2 users (show)



Attachments
Initail patch file to limit impact (9.89 KB, text/plain)
2012-11-12 11:34 UTC, Alan Davis
Details
Example xls that hangs POI (9.32 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2012-11-12 18:21 UTC, Alan Davis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Davis 2012-11-12 11:34:00 UTC
Created attachment 29588 [details]
Initail patch file to limit impact

DataFormatter Fractions formats that use 4 digits ("# #/####) or more are VERY slow. 4 digits takes around 1 second to process, 5 digits 100 seconds and so on.

To compound the issue:
  a) if there is a -ve format (N in the P;NZ;T format), the length of the N format is added to the digit count, resulting in a locked up CPU. For example "# #/#;# #/#" is taken to be the same as "# #/#######" (7 digits).
  b) Custom text is also counted. For example: "# #/#"Credits" is taken to be "# #/##########"

The attached patch tries to limit the impact of the issue rather than fix the code that calculates the fraction:
 - It limits the number of digits to 4 (additional # chars are ignored)
 - It splits of the N part of the format (if it exists) from the P part
 - It ignores any custom text (appears not to be generally supported elsewhere)
 - Adds support for negative numbers
 - Fixes a bug in calculations of negative numbers
 - Adds a number of unit tests for fractions
 - When there are both P and N parts, a FractionFormat is only now used if both
   parts include #/# OR ?/?
Comment 1 Alan Davis 2012-11-12 18:21:26 UTC
Created attachment 29591 [details]
Example xls that hangs POI
Comment 2 Yegor Kozlov 2012-11-16 09:46:58 UTC
Thanks for the patch, applied in r1410269

Yegor