[ 
https://issues.apache.org/jira/browse/TAJO-1093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14159010#comment-14159010
 ] 

ASF GitHub Bot commented on TAJO-1093:
--------------------------------------

GitHub user ykrips opened a pull request:

    https://github.com/apache/tajo/pull/177

    TAJO-1093: DateTimeFormat.to_char() is slower than SimpleDateFormat.form...

    String.format function internally uses the regular expression in its 
implementation. Using regular expression is expensive to use.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ykrips/tajo TAJO-1093

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tajo/pull/177.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #177
    
----
commit 127b2026b8b3cc010cce738706543f606dc69d18
Author: Jihun Kang <[email protected]>
Date:   2014-10-04T06:54:11Z

    TAJO-1093: DateTimeFormat.to_char() is slower than SimpleDateFormat.format()

----


> 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)

Reply via email to