[
https://issues.apache.org/jira/browse/TAJO-1093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14158946#comment-14158946
]
Jihun Kang commented on TAJO-1093:
----------------------------------
I have quicked reviewed the DateTimeFormat class, and found out the main reason
of this bottleneck. DateTimeFormat class uses the String.format function to
represent the numeric expressions, but it is very expensive functions to run. I
modified the DateTimeFormat class, and I got a significant improvement on
to_char function. I will post a patch of this issue after running several tests
on this class.
DateTimeFormat.to_char: 995 ms
SimpleDateFormat.format: 854 ms
DateTimeFormat.parseDateTime: 846 ms
SimpleDateFormat.parse: 1550 ms
> DateTimeFormat.to_char() is slower than SimpleDateFormat.format()
> -----------------------------------------------------------------
>
> Key: TAJO-1093
> URL: https://issues.apache.org/jira/browse/TAJO-1093
> Project: Tajo
> Issue Type: Improvement
> Reporter: Hyoungjun Kim
> Assignee: Jihun Kang
> Priority: Minor
>
> I tested DateTimeFormat class with the below code.
> {code}
> TimeMeta tm = new TimeMeta();
> DateTimeUtil.toJulianTimeMeta(DateTimeUtil.javaTimeToJulianTime(System.currentTimeMillis()),
> tm);
> int iteration = 1000000;
> long startTime = System.currentTimeMillis();
> for (int i = 0; i < iteration; i++) {
> DateTimeFormat.to_char(tm, "YYYY-MM-DD HH24:MI:SS");
> }
> long endTime = System.currentTimeMillis();
> System.out.println("DateTimeFormat.to_char: " + (endTime - startTime) + "
> ms");
> ///////////////////////////////////////////////////////////
> SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> Date date = new Date();
> startTime = System.currentTimeMillis();
> for (int i = 0; i < iteration; i++) {
> df.format(date);
> }
> endTime = System.currentTimeMillis();
> System.out.println("SimpleDateFormat.format: " + (endTime - startTime) + "
> ms");
> ///////////////////////////////////////////////////////////
> startTime = System.currentTimeMillis();
> for (int i = 0; i < iteration; i++) {
> DateTimeFormat.parseDateTime("2014-01-01 12:11:11", "YYYY-MM-DD
> HH24:MI:SS");
> }
> endTime = System.currentTimeMillis();
> System.out.println("DateTimeFormat.parseDateTime: " + (endTime - startTime) +
> " ms");
> ///////////////////////////////////////////////////////////
> startTime = System.currentTimeMillis();
> for (int i = 0; i < iteration; i++) {
> df.parse("2014-01-01 12:11:11");
> }
> endTime = System.currentTimeMillis();
> System.out.println("SimpleDateFormat.parse: " + (endTime - startTime) + "
> ms");
> {code}
> The following is the test result. DateTimeFormat.to_char is 20 times slower
> than SimpleDateFormat.format.
> {noformat}
> DateTimeFormat.to_char: 6993 ms
> SimpleDateFormat.format: 373 ms
> DateTimeFormat.parseDateTime: 798 ms
> SimpleDateFormat.parse: 1400 ms
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)