Uploaded image for project: 'Tajo'
  1. Tajo
  2. TAJO-1093

DateTimeFormat.to_char() is slower than SimpleDateFormat.format()

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.0
    • Component/s: Data Type
    • Labels:

      Description

      I tested DateTimeFormat class with the below 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");
      

      The following is the test result. DateTimeFormat.to_char is 20 times slower than SimpleDateFormat.format.

      DateTimeFormat.to_char: 6993 ms
      SimpleDateFormat.format: 373 ms
      DateTimeFormat.parseDateTime: 798 ms
      SimpleDateFormat.parse: 1400 ms
      

        Attachments

          Activity

            People

            • Assignee:
              ykrips Jihun Kang
              Reporter:
              hjkim Hyoungjun Kim
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: