doortts doortts 2018-02-22
global: Log elapsed time of booting sequence
@758349c67c81262e24e7a0331287522de5a93bf9
app/Global.java
--- app/Global.java
+++ app/Global.java
@@ -158,17 +158,27 @@
         isSecretInvalid = equalsDefaultSecret();
         insertInitialData();
 
+        Timestamp timestamp = new Timestamp("=== Yona server starting initialization ===");
         Config.onStart();
+        timestamp.logElapsedTime("--- Config reading: ok!");
         Property.onStart();
+        timestamp.logElapsedTime("--- Property reading: ok!");
         PullRequest.onStart();
+        timestamp.logElapsedTime("--- Pull request checking: ok!");
         NotificationMail.onStart();
+        timestamp.logElapsedTime("--- Notification mail scheduler: ok!");
         NotificationEvent.onStart();
+        timestamp.logElapsedTime("--- Notification event cleanup scheduler: ok!");
         Attachment.onStart();
+        timestamp.logElapsedTime("--- Temporary files cleanup scheduler: ok!");
         AccessControl.onStart();
+        timestamp.logElapsedTime("--- Basic access controller config reading: ok!");
 
         if (!isSecretInvalid) {
             YobiUpdate.onStart();
+            timestamp.logElapsedTime("--- Update checker run: ok! ");
             mailboxService.start();
+            timestamp.logElapsedTime("--- MailboxService checker run: ok!");
         }
 
         PlayAuthenticate.setResolver(new PlayAuthenticate.Resolver() {
 
app/utils/Timestamp.java (added)
+++ app/utils/Timestamp.java
@@ -0,0 +1,24 @@
+/**
+ * Yona, 21st Century Project Hosting SW
+ * <p>
+ * Copyright Yona & Yobi Authors & NAVER Corp. & NAVER LABS Corp.
+ * https://yona.io
+ **/
+
+package utils;
+
+public class Timestamp {
+
+    private long lastCheckedTime;
+
+    public Timestamp(String title) {
+        this.lastCheckedTime =  System.currentTimeMillis();
+        play.Logger.info(title);
+    }
+
+    public void logElapsedTime(String message) {
+        long currentTimeMillis = System.currentTimeMillis();
+        play.Logger.info(message + " - " + (currentTimeMillis - lastCheckedTime) + " ms");
+        lastCheckedTime = currentTimeMillis;
+    }
+}
Add a comment
List