You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Richard Liang (JIRA)" <ji...@apache.org> on 2006/08/31 11:19:22 UTC

[jira] Created: (HARMONY-1359) [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method

[classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method
--------------------------------------------------------------------------------

                 Key: HARMONY-1359
                 URL: http://issues.apache.org/jira/browse/HARMONY-1359
             Project: Harmony
          Issue Type: Improvement
          Components: Classlib
            Reporter: Richard Liang
            Priority: Minor


Hello,

In this method, we first try to separate the string into three parts and validate each part of the string,then pass the validated whole string to a SimpleDateFormat object which do the real parsing job.It seems likely that the validating work and the parsing work are duplicate. And each time to invoke the java.sql.Date.valueOf() method, we need to get a new instance of SimpleDateFormat,this is inefficient because constructing a new SimpleDateFormat is costly.

Best regards,
Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1359) [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1359?page=comments#action_12432084 ] 
            
Paulex Yang commented on HARMONY-1359:
--------------------------------------

Richard, any micro-benchmark data to show the difference before and after the modification?

> [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method
> --------------------------------------------------------------------------------
>
>                 Key: HARMONY-1359
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1359
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>            Reporter: Richard Liang
>         Assigned To: Paulex Yang
>            Priority: Minor
>         Attachments: Harmony-1359.diff
>
>
> Hello,
> In this method, we first try to separate the string into three parts and validate each part of the string,then pass the validated whole string to a SimpleDateFormat object which do the real parsing job.It seems likely that the validating work and the parsing work are duplicate. And each time to invoke the java.sql.Date.valueOf() method, we need to get a new instance of SimpleDateFormat,this is inefficient because constructing a new SimpleDateFormat is costly.
> Best regards,
> Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Assigned: (HARMONY-1359) [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1359?page=all ]

Paulex Yang reassigned HARMONY-1359:
------------------------------------

    Assignee: Paulex Yang

> [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method
> --------------------------------------------------------------------------------
>
>                 Key: HARMONY-1359
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1359
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>            Reporter: Richard Liang
>         Assigned To: Paulex Yang
>            Priority: Minor
>         Attachments: Harmony-1359.diff
>
>
> Hello,
> In this method, we first try to separate the string into three parts and validate each part of the string,then pass the validated whole string to a SimpleDateFormat object which do the real parsing job.It seems likely that the validating work and the parsing work are duplicate. And each time to invoke the java.sql.Date.valueOf() method, we need to get a new instance of SimpleDateFormat,this is inefficient because constructing a new SimpleDateFormat is costly.
> Best regards,
> Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1359) [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method

Posted by "Richard Liang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1359?page=all ]

Richard Liang updated HARMONY-1359:
-----------------------------------

    Attachment: Harmony-1359.diff

Hello,

Would you please try this patch? Please apply this patch after Harmony-1358. 

Thanks a lot.

Best regards,
Richard

> [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method
> --------------------------------------------------------------------------------
>
>                 Key: HARMONY-1359
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1359
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>            Reporter: Richard Liang
>            Priority: Minor
>         Attachments: Harmony-1359.diff
>
>
> Hello,
> In this method, we first try to separate the string into three parts and validate each part of the string,then pass the validated whole string to a SimpleDateFormat object which do the real parsing job.It seems likely that the validating work and the parsing work are duplicate. And each time to invoke the java.sql.Date.valueOf() method, we need to get a new instance of SimpleDateFormat,this is inefficient because constructing a new SimpleDateFormat is costly.
> Best regards,
> Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1359) [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method

Posted by "Richard Liang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1359?page=comments#action_12432111 ] 
            
Richard Liang commented on HARMONY-1359:
----------------------------------------

Thanks a lot, Paulex.

The fix looks good.

Best regards,
Richard

> [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method
> --------------------------------------------------------------------------------
>
>                 Key: HARMONY-1359
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1359
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>            Reporter: Richard Liang
>         Assigned To: Paulex Yang
>            Priority: Minor
>         Attachments: Harmony-1359.diff
>
>
> Hello,
> In this method, we first try to separate the string into three parts and validate each part of the string,then pass the validated whole string to a SimpleDateFormat object which do the real parsing job.It seems likely that the validating work and the parsing work are duplicate. And each time to invoke the java.sql.Date.valueOf() method, we need to get a new instance of SimpleDateFormat,this is inefficient because constructing a new SimpleDateFormat is costly.
> Best regards,
> Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1359) [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method

Posted by "Richard Liang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1359?page=comments#action_12432104 ] 
            
Richard Liang commented on HARMONY-1359:
----------------------------------------

Hello Paulex,

Please refer to the "micro-benchmark" data: 

public void test_performance() {
        for (int i = 0; i < 10000; i++) {
            Date.valueOf("1911-11-11");
        }
        long before = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            Date.valueOf("1911-11-11");
        }
        long after = System.currentTimeMillis();
        System.out.println(after - before);
    }

before : about 1600 milliseconds
after the patch is applied: about 60 milliseconds
The efficiency improved about 25 times than the original code.


Best regards,
Richard

> [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method
> --------------------------------------------------------------------------------
>
>                 Key: HARMONY-1359
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1359
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>            Reporter: Richard Liang
>         Assigned To: Paulex Yang
>            Priority: Minor
>         Attachments: Harmony-1359.diff
>
>
> Hello,
> In this method, we first try to separate the string into three parts and validate each part of the string,then pass the validated whole string to a SimpleDateFormat object which do the real parsing job.It seems likely that the validating work and the parsing work are duplicate. And each time to invoke the java.sql.Date.valueOf() method, we need to get a new instance of SimpleDateFormat,this is inefficient because constructing a new SimpleDateFormat is costly.
> Best regards,
> Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Closed: (HARMONY-1359) [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1359?page=all ]

Paulex Yang closed HARMONY-1359.
--------------------------------


Verified by Richard.

> [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method
> --------------------------------------------------------------------------------
>
>                 Key: HARMONY-1359
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1359
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>            Reporter: Richard Liang
>         Assigned To: Paulex Yang
>            Priority: Minor
>         Attachments: Harmony-1359.diff
>
>
> Hello,
> In this method, we first try to separate the string into three parts and validate each part of the string,then pass the validated whole string to a SimpleDateFormat object which do the real parsing job.It seems likely that the validating work and the parsing work are duplicate. And each time to invoke the java.sql.Date.valueOf() method, we need to get a new instance of SimpleDateFormat,this is inefficient because constructing a new SimpleDateFormat is costly.
> Best regards,
> Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (HARMONY-1359) [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1359?page=all ]

Paulex Yang resolved HARMONY-1359.
----------------------------------

    Resolution: Fixed

Richard, patch applied at revision r439254, thanks a lot for this enhancement, please verify that the problem is fully fixed as you expected.


> [classlib][sql] Improve the performance of java.sql.Date.valueOf(String ) method
> --------------------------------------------------------------------------------
>
>                 Key: HARMONY-1359
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1359
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>            Reporter: Richard Liang
>         Assigned To: Paulex Yang
>            Priority: Minor
>         Attachments: Harmony-1359.diff
>
>
> Hello,
> In this method, we first try to separate the string into three parts and validate each part of the string,then pass the validated whole string to a SimpleDateFormat object which do the real parsing job.It seems likely that the validating work and the parsing work are duplicate. And each time to invoke the java.sql.Date.valueOf() method, we need to get a new instance of SimpleDateFormat,this is inefficient because constructing a new SimpleDateFormat is costly.
> Best regards,
> Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira