From 982b8703a757e5a91aa6451fd26593a065f8a452 Mon Sep 17 00:00:00 2001 From: Rastislav Szabo Date: Fri, 7 Jul 2017 12:36:17 +0200 Subject: added performance benchmark example Change-Id: Ia0fea0569be3da7fadac9ef32d5f12c0b6de0089 Signed-off-by: Rastislav Szabo --- core/request_handler.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'core/request_handler.go') diff --git a/core/request_handler.go b/core/request_handler.go index f4f5e92..e0235b9 100644 --- a/core/request_handler.go +++ b/core/request_handler.go @@ -79,13 +79,15 @@ func (c *Connection) processRequest(ch *api.Channel, chMeta *channelMetadata, re return error } - // send the message - log.WithFields(logger.Fields{ - "context": chMeta.id, - "msg_id": msgID, - "msg_size": len(data), - }).Debug("Sending a message to VPP.") + if log.Level == logger.DebugLevel { // for performance reasons - logrus does some processing even if debugs are disabled + log.WithFields(logger.Fields{ + "context": chMeta.id, + "msg_id": msgID, + "msg_size": len(data), + }).Debug("Sending a message to VPP.") + } + // send the message if req.Multipart { // expect multipart response atomic.StoreUint32(&chMeta.multipart, 1) @@ -121,11 +123,13 @@ func msgCallback(context uint32, msgID uint16, data []byte) { return } - log.WithFields(logger.Fields{ - "context": context, - "msg_id": msgID, - "msg_size": len(data), - }).Debug("Received a message from VPP.") + if log.Level == logger.DebugLevel { // for performance reasons - logrus does some processing even if debugs are disabled + log.WithFields(logger.Fields{ + "context": context, + "msg_id": msgID, + "msg_size": len(data), + }).Debug("Received a message from VPP.") + } if context == 0 || conn.isNotificationMessage(msgID) { // process the message as a notification -- cgit 1.2.3-korg