You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2018/11/29 09:29:18 UTC

[incubator-plc4x] 02/02: - Added profiling to the edgent adapter.

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

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git

commit 829cbae9269df68b4837c6190b02dc4639bb467e
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Nov 29 10:29:13 2018 +0100

    - Added profiling to the edgent adapter.
---
 .../java/org/apache/plc4x/edgent/PlcConnectionAdapter.java     | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java b/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java
index 01ceb8d..822a503 100644
--- a/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java
+++ b/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
+import java.time.temporal.ChronoUnit;
 import java.util.Collections;
 import java.util.List;
 
@@ -116,7 +117,14 @@ public class PlcConnectionAdapter implements AutoCloseable {
                 PlcConnection connection = null;
                 try {
                     connection = getConnection();
-                    return readRequest.execute().get();
+                    LocalDateTime start = LocalDateTime.now();
+                    PlcReadResponse plcReadResponse = readRequest.execute().get();
+                    LocalDateTime end = LocalDateTime.now();
+                    if(logger.isTraceEnabled()) {
+                        long diff = ChronoUnit.MILLIS.between(start, end);
+                        logger.trace("Processed request in " + diff + "ms");
+                    }
+                    return plcReadResponse;
                 } catch (Exception e) {
                     logger.error("reading from plc device {} {} failed", connection, readRequest, e);
                     return null;