Add profiling to selected DAs

This commit is contained in:
2025-04-11 17:07:48 -04:00
parent acbd29948a
commit b0075feee9
4 changed files with 67 additions and 26 deletions

View File

@@ -12,6 +12,7 @@ namespace MarketData.DataAccess
}
public static bool CheckFundamentalModifiedOn(String symbol,DateTime modified)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand =null;
@@ -43,10 +44,12 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static DateTime GetLatestDate(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -79,10 +82,12 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if(null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static TimeSeriesCollection GetTotalCashMils(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand =null;
@@ -122,10 +127,12 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static TimeSeriesCollection GetPERatio(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand =null;
@@ -165,10 +172,12 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static TimeSeriesCollection GetEPS(String symbol,DateTime? maxDate=null)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand = null;
@@ -209,10 +218,12 @@ namespace MarketData.DataAccess
if (null != sqlCommand) sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static Fundamental GetFundamental(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand =null;
@@ -275,10 +286,12 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static Fundamental GetFundamental(String symbol, DateTime asof)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -344,11 +357,13 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
// get the maximum date on record on or before asof
public static DateTime? GetMaxDateFromFundamental(String symbol,DateTime asof)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -382,10 +397,12 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static Fundamental GetFundamentalMaxDate(String symbol, DateTime asof)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -455,11 +472,13 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static Fundamentals GetFundamentalMaxDateTop(String symbol, DateTime asof, int top)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -535,11 +554,13 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static bool InsertFundamentals(Fundamentals fundamentals)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlTransaction sqlTransaction = null;
String strQuery = null;
@@ -630,11 +651,13 @@ namespace MarketData.DataAccess
{
if(null!=sqlTransaction)sqlTransaction.Dispose();
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static bool InsertFundamental(Fundamental fundamental)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlTransaction sqlTransaction = null;
String strQuery = null;
@@ -721,6 +744,7 @@ namespace MarketData.DataAccess
{
if(null!=sqlTransaction)sqlTransaction.Dispose();
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
private static bool DeleteFundamentals(Fundamentals fundamentals, MySqlConnection sqlConnection, MySqlTransaction sqlTransaction)
@@ -733,6 +757,7 @@ namespace MarketData.DataAccess
}
private static bool DeleteFundamental(Fundamental fundamental, MySqlConnection sqlConnection, MySqlTransaction sqlTransaction)
{
Profiler profiler = new Profiler();
StringBuilder sb = new StringBuilder();
String strQuery = null;
@@ -758,6 +783,7 @@ namespace MarketData.DataAccess
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
}