harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Qiu (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-5958) [classlib][sql][performance] - improve performance of java.sql.Date/Time/Timestamp.toString()
Date Thu, 28 Aug 2008 01:30:44 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-5958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12626400#action_12626400
] 

Sean Qiu commented on HARMONY-5958:
-----------------------------------

Here is a small test from Regis:

----------
 int count = 5000;

for (int i = 0; i < count; ++i) { new Date(new
java.util.Date().getTime()).toString(); }

Date date = new Date(new java.util.Date().getTime());
long start = System.currentTimeMillis();

for (int i = 0; i < count; ++i) { date.toString(); }
long end = System.currentTimeMillis();
System.out.println("Invoke Date.toString() " + count + " times, cost:
" + (end - start));

Time time = new Time(new java.util.Date().getTime());
start = System.currentTimeMillis();
for (int i = 0; i < count; ++i) { time.toString(); }
end = System.currentTimeMillis();
System.out.println("Invoke Time.toString() " + count + " times, cost:
" + (end - start));

Timestamp timestamp = new Timestamp(new java.util.Date().getTime());
start = System.currentTimeMillis();
for (int i = 0; i < count; ++i) { timestamp.toString(); }
end = System.currentTimeMillis();
System.out.println("Invoke Timestamp.toString() " + count + " times,
cost: " + (end - start));
-------------

the first loop, give time for jvm to warm up

Below data compare the two implementations:

before the patch:
Invoke Date.toString() 5000 times, cost: 6757
Invoke Time.toString() 5000 times, cost: 7699
Invoke Timestamp.toString() 5000 times, cost: 2527

after the patch:
Invoke Date.toString() 5000 times, cost: 84
Invoke Time.toString() 5000 times, cost: 95
Invoke Timestamp.toString() 5000 times, cost: 272


> [classlib][sql][performance] - improve performance of java.sql.Date/Time/Timestamp.toString()
> ---------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5958
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5958
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>    Affects Versions: 5.0M6
>            Reporter: Regis Xu
>            Assignee: Sean Qiu
>             Fix For: 5.0M8
>
>         Attachments: HARMONY-5958.diff
>
>
> java.sql.Date/Time/Timestamp.toString() use SimpleDateFormat and DecimalFormat to generate
string format of the date, which is too slow and complex for the toString() methods.
> I re-implement them by hand, and boost the speed a lot. I will attach the patch soon.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message