changeset 1285:1c53cc761dcd

BlockFactory - performance improvements
author Devel 2
date Fri, 10 Jul 2020 08:38:17 +0200
parents 8527e4c0f984
children 356c10f8b486
files stress-tester/src/main/java/com/passus/st/reader/pcapng/block/BlockFactory.java
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/pcapng/block/BlockFactory.java	Thu Jul 09 15:11:35 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/reader/pcapng/block/BlockFactory.java	Fri Jul 10 08:38:17 2020 +0200
@@ -1,13 +1,13 @@
 package com.passus.st.reader.pcapng.block;
 
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
 import java.nio.ByteOrder;
 import java.util.ArrayList;
 import java.util.List;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 
 /**
- *
  * @author mikolaj.podbielski
  */
 public class BlockFactory {
@@ -15,11 +15,14 @@
     private static final Logger LOGGER = LogManager.getLogger(BlockFactory.class);
 
     private SectionHeaderBlock shb;
+
     private List<InterfaceDescriptionBlock> idbs;
 
     public Block createBlock(int type, byte[] data, ByteOrder byteOrder) {
-        String message = String.format("block type=%08x %25s size=%d", type, BlockNames.getBlockName(type), data.length);
-        LOGGER.debug(message);
+        if (LOGGER.isDebugEnabled()) {
+            String message = String.format("block type=%08x %25s size=%d", type, BlockNames.getBlockName(type), data.length);
+            LOGGER.debug(message);
+        }
 
         switch (type) {
             case SectionHeaderBlock.TYPE: {