You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by jo...@apache.org on 2021/07/05 19:23:51 UTC

[sling-org-apache-sling-engine] 01/01: SLING-10582 report filter timings also in microseconds

This is an automated email from the ASF dual-hosted git repository.

joerghoh pushed a commit to branch improvement/SLING-10582-filter-timing-in-microseconds
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-engine.git

commit 5acee0abee8cbf335b7179864e24ac90bd406bfa
Author: Joerg Hoh <jh...@adobe.com>
AuthorDate: Mon Jul 5 21:22:30 2021 +0200

    SLING-10582 report filter timings also in microseconds
---
 .../apache/sling/engine/impl/filter/AbstractSlingFilterChain.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/sling/engine/impl/filter/AbstractSlingFilterChain.java b/src/main/java/org/apache/sling/engine/impl/filter/AbstractSlingFilterChain.java
index 245f8b5..12af6c8 100644
--- a/src/main/java/org/apache/sling/engine/impl/filter/AbstractSlingFilterChain.java
+++ b/src/main/java/org/apache/sling/engine/impl/filter/AbstractSlingFilterChain.java
@@ -51,7 +51,7 @@ public abstract class AbstractSlingFilterChain implements FilterChain {
             throws ServletException, IOException {
 
         final int filterIdx = ++this.current;
-        final long start = System.currentTimeMillis();
+        final long start = System.nanoTime();
 
         if (filterIdx > this.filters.length) {
             //this happens when the whole filter chain has been executed, and a filter in that chain,
@@ -90,7 +90,7 @@ public abstract class AbstractSlingFilterChain implements FilterChain {
 
         } finally {
             if (filterIdx < times.length) {
-                times[filterIdx] = System.currentTimeMillis() - start;
+                times[filterIdx] = (System.nanoTime() - start) / 1000;
                 if (filterIdx == 0) {
                     consolidateFilterTimings(slingRequest);
                 }
@@ -122,7 +122,7 @@ public abstract class AbstractSlingFilterChain implements FilterChain {
             for (int i = filters.length - 1; i > 0; i--) {
                 filters[i].trackTime(times[i] - times[i + 1]);
                 if (tracker != null) {
-                    tracker.log("Filter timing: filter={0}, inner={1}, total={2}, outer={3}",
+                    tracker.log("Filter timing: filter={0}, inner={1,number,#}, total={2,number,#}, outer={3,number,#}",
                         filters[i].getFilter().getClass().getName(), times[i + 1], times[i], (times[i] - times[i + 1]));
                 }
             }