save timing debug log
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Mon, 16 Nov 2015 11:24:36 +0000 (12:24 +0100)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Mon, 16 Nov 2015 11:26:16 +0000 (12:26 +0100)
platform/configuration-store-impl/src/ComponentStoreImpl.kt

index 8e0294ddc158519f8de8d970e0fbd7600410f834..07b7e8fe2cd7efc7d9bdd6be27f11c123e6a1e05 100644 (file)
@@ -117,8 +117,21 @@ abstract class ComponentStoreImpl : IComponentStore {
     if (externalizationSession != null) {
       val names = ArrayUtilRt.toStringArray(components.keys)
       Arrays.sort(names)
+      val timeLogPrefix = "Saving"
+      var timeLog = if (LOG.isDebugEnabled) StringBuilder(timeLogPrefix) else null
       for (name in names) {
+        val start = if (timeLog == null) 0 else System.currentTimeMillis()
         commitComponent(externalizationSession, components.get(name)!!, name)
+        timeLog?.let {
+          val duration = System.currentTimeMillis() - start
+          if (duration > 10) {
+            it.append("\n").append(name).append(" took ").append(duration).append(" ms: ").append((duration / 60000)).append(" min ").append(((duration % 60000) / 1000)).append("sec")
+          }
+        }
+      }
+
+      if (timeLog != null && timeLog.length > timeLogPrefix.length) {
+        LOG.debug(timeLog.toString())
       }
     }