Skip to content

Commit

Permalink
Remove overhead at TraceRow method when log is turned off.
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiamurialdo committed Dec 7, 2023
1 parent 718aca3 commit 37fcfe3
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 31 deletions.
4 changes: 2 additions & 2 deletions dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@ public class GxDataReader: IDataReader
protected string stmt;
protected GxConnectionCache cache;
protected IGxConnection con;
protected GxArrayList block;
protected List<object[]> block;
protected string key;
protected int pos;
protected bool cached;
Expand Down Expand Up @@ -2208,7 +2208,7 @@ public GxDataReader( IGxConnectionManager connManager, GxDataRecord dr, IGxConne
reader=dr.GetCommand(con,stmt,parameters).ExecuteReader();
cache.SetAvailableCommand(stmt, false, dynStmt);
open=true;
block=new GxArrayList(fetchSize);
block= new List<object[]>(fetchSize);
pos=-1;
if (cached)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Reflection;
Expand Down Expand Up @@ -570,7 +571,7 @@ public GxMySQLConnectorDataReader(IGxConnectionManager connManager, GxDataRecord
reader = cmd.ExecuteReader();
cache.SetAvailableCommand(stmt, false, dynStmt);
open = true;
block = new GxArrayList(fetchSize);
block = new List<object[]>(fetchSize);
pos = -1;
if (cached)
{
Expand Down Expand Up @@ -622,7 +623,7 @@ public GxMySQLConnectorCursorDataReader(IGxConnectionManager connManager, GxData
reader = cmd.ExecuteReader();
cache.SetAvailableCommand(stmt, false, dynStmt);
open = true;
block = new GxArrayList(fetchSize);
block = new List<object[]>(fetchSize);
pos = -1;
if (cached)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Text;
Expand Down Expand Up @@ -497,7 +498,7 @@ public GxMySQLDriverCSDataReader(IGxConnectionManager connManager, GxDataRecord
reader = cmd.ExecuteReader();
cache.SetAvailableCommand(stmt, false, dynStmt);
open = true;
block = new GxArrayList(fetchSize);
block = new List<object[]>(fetchSize);
pos = -1;
if (cached)
{
Expand Down Expand Up @@ -542,7 +543,7 @@ public GxMySQLDriverCSCursorDataReader(IGxConnectionManager connManager, GxDataR
reader = cmd.ExecuteReader();
cache.SetAvailableCommand(stmt, false, dynStmt);
open = true;
block = new GxArrayList(fetchSize);
block = new List<object[]>(fetchSize);
pos = -1;
if (cached)
{
Expand Down
46 changes: 23 additions & 23 deletions dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ public GXFatFieldGetter(GxCommand gxDbCommand)
{
_gxDbCommand = gxDbCommand;
}
void TraceRow(params string[] list)
void TraceRow(Func<string> buildMsg)
{
if (_gxDbCommand.HasMoreRows)
{
GXLogging.Trace(log, list);
GXLogging.Trace(log, buildMsg);
}
}
public IDataReader DataReader
Expand All @@ -225,57 +225,57 @@ public IDataReader DataReader
public short getShort(int id)
{
short value = _gxDbCommand.Db.GetShort(_gxDbCommand, _DR, id - 1);
TraceRow("getShort - index : ", id.ToString(), " value:", value.ToString());
TraceRow(()=> $"getShort - index : {id} value:{value}");
return value;
}
public int getInt(int id)
{
int value = _gxDbCommand.Db.GetInt(_gxDbCommand, _DR, id - 1);
TraceRow("getInt - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getInt - index : {id} value:{value}");
return value;
}
public bool getBool(int id)
{
bool value = _gxDbCommand.Db.GetBoolean(_gxDbCommand, _DR, id - 1);
TraceRow("getBool - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getBool - index : {id} value:{value}");
return value;
}
public Guid getGuid(int id)
{
Guid value = _gxDbCommand.Db.GetGuid(_gxDbCommand, _DR, id - 1);
TraceRow("getGuid - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getGuid - index : {id} value:{value}");
return value;
}
public long getLong(int id)
{
long value = _gxDbCommand.Db.GetLong(_gxDbCommand, _DR, id - 1);
TraceRow("getLong - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getLong - index : {id} value:{value}");
return value;

}
public double getDouble(int id)
{
double value= _gxDbCommand.Db.GetDouble(_gxDbCommand, _DR, id - 1);
TraceRow("getDouble - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getDouble - index : {id} value:{value}");
return value;
}
public Decimal getDecimal(int id)
{
Decimal value= _gxDbCommand.Db.GetDecimal(_gxDbCommand, _DR, id - 1);
TraceRow("getDecimal - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getDecimal - index : {id} value:{value}");
return value;

}
public string getString(int id, int size)
{
String value = _gxDbCommand.Db.GetString(_gxDbCommand, _DR, id - 1, size);
TraceRow("getString - index : ", id.ToString(), " value:", (value!=null ? value.ToString(): string.Empty));
TraceRow(() => $"getString - index : {id} value:{(value!=null ? value.ToString(): string.Empty)}");
return value;
}
public DateTime getDateTime(int id)
{
DateTime value = _gxDbCommand.Db.GetDateTime(_gxDbCommand, _DR, id - 1);
TraceRow("getDateTime - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getDateTime - index : {id} value:{value}");
return value;
}
public DateTime getDateTime(int id, Boolean precision)
Expand All @@ -287,19 +287,19 @@ public DateTime getDateTime(int id, Boolean precision)
else {
value = _gxDbCommand.Db.GetDateTime(_gxDbCommand, _DR, id - 1);
}
TraceRow("getDateTime - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getDateTime - index : {id} value:{value}");
return value;
}
public DateTime getDate(int id)
{
DateTime value = _gxDbCommand.Db.GetDate(_gxDbCommand, _DR, id - 1);
TraceRow("getDate - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getDate - index : {id} value:{value}");
return value;
}
public string getLongVarchar(int id)
{
string value = _gxDbCommand.Db.GetString(_gxDbCommand, _DR, id - 1);
TraceRow("getLongVarchar - index : ", id.ToString(), " value:", (value!=null ? value.ToString(): string.Empty));
TraceRow(() => $"getLongVarchar - index : {id} value:{(value != null ? value.ToString() : string.Empty)}");
return value;
}
public DateTime getGXDateTime(int id, Boolean precision)
Expand All @@ -309,7 +309,7 @@ public DateTime getGXDateTime(int id, Boolean precision)
#else
DateTime value = DateTimeUtil.DBserver2local(getDateTime(id, precision), _gxDbCommand.Conn.ClientTimeZone);
#endif
TraceRow("getDateTime - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getDateTime - index : {id} value:{value}");
return value;
}
public DateTime getGXDateTime(int id)
Expand All @@ -319,27 +319,27 @@ public DateTime getGXDateTime(int id)
#else
DateTime value = DateTimeUtil.DBserver2local(getDateTime(id, false), _gxDbCommand.Conn.ClientTimeZone);
#endif
TraceRow("getGXDateTime - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getGXDateTime - index : {id} value:{value.ToString()}");
return value;
}
public DateTime getGXDate(int id)
{
DateTime value = getDate(id);
TraceRow("getGXDate - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getGXDate - index : {id} value:{value.ToString()}");
return value;
}
public string getBLOBFile(int id)
{
string value= getBLOBFile(id, "tmp", "");
TraceRow("getBLOBFile - index : ", id.ToString(), " value:", (value!=null ? value.ToString() : string.Empty));
TraceRow(() => $"getBLOBFile - index : {id} value:{(value != null ? value.ToString() : string.Empty)}");
return value;
}

public string getBLOBFile(int id, string extension, string name)
{
string fileName = FileUtil.getTempFileName(_gxDbCommand.Conn.BlobPath, name, extension, GxFileType.Private);
String value = getBLOBFile(id, extension, name, fileName, true);
TraceRow("getBLOBFile - index : ", id.ToString(), " value:", (value!=null ? value.ToString() : string.Empty));
TraceRow(() => $"getBLOBFile - index : {id} value:{(value != null ? value.ToString() : string.Empty)}");
return value;
}

Expand Down Expand Up @@ -389,7 +389,7 @@ private string getBLOBFile(int id, string extension, string name, string fileNam
}
streamClosed = true;

TraceRow("GetBlobFile fileName:" + fileName + ", retval bytes:" + retval);
TraceRow(() => $"GetBlobFile fileName:{fileName}, retval bytes:{retval}");

if (temporary)
GXFileWatcher.Instance.AddTemporaryFile(file, _gxDbCommand.Conn.DataStore.Context);
Expand Down Expand Up @@ -473,20 +473,20 @@ public string getMultimediaUri(int id, bool absUrl)
public string getVarchar(int id)
{
string value = _gxDbCommand.Db.GetString(_gxDbCommand, _DR, id - 1);
TraceRow("getVarchar - index : ", id.ToString(), " value:", (value != null ? value.ToString() : string.Empty));
TraceRow(() => $"getVarchar - index : {id} value:{(value != null ? value.ToString() : string.Empty)}");
return value;
}
public decimal getBigDecimal(int id, int dec)
{
decimal value =_gxDbCommand.Db.GetDecimal(_gxDbCommand, _DR, id - 1);
TraceRow("getBigDecimal - index : ", id.ToString(), " value:", value.ToString());
TraceRow(() => $"getBigDecimal - index : {id} value:{value.ToString()}");
return value;
}

public IGeographicNative getGeospatial(int id)
{
IGeographicNative value = _gxDbCommand.Db.GetGeospatial(_gxDbCommand, _DR, id - 1);
TraceRow("getGeospatial - index : ", id.ToString(), " value:", (value != null ? value.ToString() : string.Empty));
TraceRow(() => $"getGeospatial - index : {id} value:{(value != null ? value.ToString() : string.Empty)}");
return value;
}

Expand Down
5 changes: 4 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,10 @@ public GxArrayList(int capacity)
{
innerArray = new List<object[]>(capacity);
}
internal GxArrayList(List<object[]> list)
{
innerArray = list;
}
public GxArrayList()
{
innerArray = new List<object[]>();
Expand Down Expand Up @@ -2076,7 +2080,6 @@ public object Item(int index, int i)
return innerArray[index][i];
}
}

[CollectionDataContract(Name = "GxUnknownObjectCollection")]
[KnownType(typeof(GxSimpleCollection<object>))]
[KnownType(typeof(GxStringCollection))]
Expand Down
12 changes: 12 additions & 0 deletions dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,18 @@ internal static void Trace(IGXLogger logger, params string[] list)
logger.LogTrace(string.Join(" ", list));
}
}
internal static void Trace(IGXLogger logger, Func<string> buildMsg)
{
if (logger != null)
{
if (logger.IsTraceEnabled)
{
string msg = buildMsg();
logger.LogTrace(msg);
}
}
}

public static void Critical(IGXLogger logger, params string[] list)
{
if (logger != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,13 @@ public class CacheItem
public CacheItem()
{
}

internal CacheItem(List<object[]> data, bool hasnext, int blockSize, long sizeInBytes)
{
Data = new GxArrayList(data);
HasNext = hasnext;
BlockSize = blockSize;
SizeInBytes = sizeInBytes;
}
public CacheItem(GxArrayList data, bool hasnext, int blockSize, long sizeInBytes)
{
Data = data;
Expand Down

0 comments on commit 37fcfe3

Please sign in to comment.