Chenjp commented on code in PR #751: URL: https://github.com/apache/tomcat/pull/751#discussion_r1756465922
########## java/org/apache/tomcat/util/http/FastHttpDateFormat.java: ########## @@ -104,8 +104,9 @@ public final class FastHttpDateFormat { */ public static String getCurrentDate() { long now = System.currentTimeMillis(); - // Handle case where time moves backwards (e.g. system time corrected) - if (Math.abs(now - currentDateGenerated) > 1000) { + // Ignore millisecond part. + now -= now % 1000L; Review Comment: Without significant improvement . 1. solution1: Duration: ***322245800ns*** (100000000 times) ```java public static String getCurrentDate() { long now = System.currentTimeMillis() / 1000L; if (now != currentDateGenerated) { currentDate = FORMAT_RFC5322.format(new Date(now*1000L)); currentDateGenerated = now; } return currentDate; } ``` 2. solution2: Duration: ***328164000ns*** (100000000 times) ```java public static String getCurrentDate() { long now = System.currentTimeMillis(); // Ignore millisecond part. now -= now % 1000L; if (now != currentDateGenerated) { currentDate = FORMAT_RFC5322.format(new Date(now)); currentDateGenerated = now; } return currentDate; } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org