You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Sean Qiu (JIRA)" <ji...@apache.org> on 2008/08/28 03:30:44 UTC
[jira] Commented: (HARMONY-5958) [classlib][sql][performance] -
improve performance of java.sql.Date/Time/Timestamp.toString()
[ 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.