Skip to content
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b492cce
Creation of backup and restore statistics can be switched off to supp…
DevM900 Jun 27, 2024
c39be07
Determination of the correct number of reads, inserts, deletes, etc. …
DevM900 Jun 28, 2024
1fd2464
Determination of the correct number of reads, inserts, deletes, etc. …
DevM900 Jun 28, 2024
9112e28
Added comments.
DevM900 Jun 28, 2024
c00d785
Merge branch 'DatabaseInfo' of https://github.com/DevM900/NETProvider…
DevM900 Jun 28, 2024
124e5f3
Type of the key of the result collection changed from "uint" to "short".
DevM900 Jul 4, 2024
c43a1bf
Type of the key of the result collection changed from "uint" to "short".
DevM900 Jul 4, 2024
72ed318
Added tests for determination of the number of reads, inserts, delete…
DevM900 Jul 4, 2024
aa0d9f7
using await
DevM900 Sep 13, 2024
2acda4a
changed to var
DevM900 Sep 13, 2024
7edc7ee
prefix on argument removed,
DevM900 Sep 13, 2024
367af06
extra spaces removed
DevM900 Sep 13, 2024
600fb37
'private' modifier removed
DevM900 Sep 13, 2024
3f1e72c
prefix 'a' on arguments removed
DevM900 Sep 13, 2024
a9311a0
Merge remote-tracking branch 'upstream/master' into DatabaseInfo
DevM900 Nov 4, 2024
cef7087
Typo statistic -> statistics
DevM900 Nov 4, 2024
e720df4
removed not needed "using"
DevM900 Nov 4, 2024
bf09d5a
changed to "var"
DevM900 Nov 4, 2024
fa0f53c
Using async/await in "GetTableNameList"
DevM900 Nov 4, 2024
9470f22
added “using” to ensure that resources are released
DevM900 Nov 4, 2024
187ab1c
moved "trim" to SQL
DevM900 Nov 4, 2024
fe4c525
added missing async/await
DevM900 Nov 6, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
using await
  • Loading branch information
DevM900 committed Sep 13, 2024
commit aa0d9f70f7b354ea6dbf4f6a37923a6817104b6e
62 changes: 32 additions & 30 deletions src/FirebirdSql.Data.FirebirdClient.Tests/FbDatabaseInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@ public void CompleteDatabaseInfoTest()
}

[Test]
public void PerformanceAnalysis_SELECT_Test()
public async Task PerformanceAnalysis_SELECT_Test()
{
IDictionary<string, short> tableNameList = GetTableNameList();
short tableIdTest = tableNameList["TEST"];

var dbInfo = new FbDatabaseInfo(Connection);
IDictionary<short, ulong> insertCount = dbInfo.GetInsertCount();
IDictionary<short, ulong> updateCount = dbInfo.GetUpdateCount();
IDictionary<short, ulong> readSeqCount = dbInfo.GetReadSeqCount();
IDictionary<short, ulong> readIdxCount = dbInfo.GetReadIdxCount();
var insertCount = await dbInfo.GetInsertCountAsync();
var updateCount = await dbInfo.GetUpdateCountAsync();
var readSeqCount = await dbInfo.GetReadSeqCountAsync();
var readIdxCount = await dbInfo.GetReadIdxCountAsync();

var fbCommand = new FbCommand("SELECT MAX(INT_FIELD) FROM TEST", Connection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await using

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not look like it's here.

var maxIntField = fbCommand.ExecuteScalar() as int?;
var maxIntField = await fbCommand.ExecuteScalarAsync() as int?;

insertCount = GetAffectedTables(insertCount, dbInfo.GetInsertCount());
updateCount = GetAffectedTables(updateCount, dbInfo.GetUpdateCount());
readSeqCount = GetAffectedTables(readSeqCount, dbInfo.GetReadSeqCount());
readIdxCount = GetAffectedTables(readIdxCount, dbInfo.GetReadIdxCount());
insertCount = GetAffectedTables(insertCount, await dbInfo.GetInsertCountAsync());
updateCount = GetAffectedTables(updateCount, await dbInfo.GetUpdateCountAsync());
readSeqCount = GetAffectedTables(readSeqCount, await dbInfo.GetReadSeqCountAsync());
readIdxCount = GetAffectedTables(readIdxCount, await dbInfo.GetReadIdxCountAsync());

Assert.That(insertCount.ContainsKey(tableIdTest), Is.False);
Assert.That(updateCount.ContainsKey(tableIdTest), Is.False);
Expand All @@ -91,24 +91,24 @@ public void PerformanceAnalysis_SELECT_Test()
}

[Test]
public void PerformanceAnalysis_INSERT_Test()
public async Task PerformanceAnalysis_INSERT_Test()
{
IDictionary<string, short> tableNameList = GetTableNameList();
short tableIdTest = tableNameList["TEST"];

var dbInfo = new FbDatabaseInfo(Connection);
IDictionary<short, ulong> insertCount = dbInfo.GetInsertCount();
IDictionary<short, ulong> updateCount = dbInfo.GetUpdateCount();
IDictionary<short, ulong> readSeqCount = dbInfo.GetReadSeqCount();
IDictionary<short, ulong> readIdxCount = dbInfo.GetReadIdxCount();
var insertCount = await dbInfo.GetInsertCountAsync();
var updateCount = await dbInfo.GetUpdateCountAsync();
var readSeqCount = await dbInfo.GetReadSeqCountAsync();
var readIdxCount = await dbInfo.GetReadIdxCountAsync();

var fbCommand = new FbCommand("INSERT INTO TEST (INT_FIELD) VALUES (900)", Connection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await using

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not look like it's here.

fbCommand.ExecuteNonQuery();
await fbCommand.ExecuteNonQueryAsync();

insertCount = GetAffectedTables(insertCount, dbInfo.GetInsertCount());
updateCount = GetAffectedTables(updateCount, dbInfo.GetUpdateCount());
readSeqCount = GetAffectedTables(readSeqCount, dbInfo.GetReadSeqCount());
readIdxCount = GetAffectedTables(readIdxCount, dbInfo.GetReadIdxCount());
insertCount = GetAffectedTables(insertCount, await dbInfo.GetInsertCountAsync());
updateCount = GetAffectedTables(updateCount, await dbInfo.GetUpdateCountAsync());
readSeqCount = GetAffectedTables(readSeqCount, await dbInfo.GetReadSeqCountAsync());
readIdxCount = GetAffectedTables(readIdxCount, await dbInfo.GetReadIdxCountAsync());

Assert.That(insertCount.ContainsKey(tableIdTest), Is.True);
Assert.That(insertCount[tableIdTest], Is.EqualTo(1));
Expand All @@ -118,7 +118,7 @@ public void PerformanceAnalysis_INSERT_Test()
}

[Test]
public void PerformanceAnalysis_UPDATE_Test()
public async Task PerformanceAnalysis_UPDATE_Test()
{
IDictionary<string, short> tableNameList = GetTableNameList();
short tableIdTest = tableNameList["TEST"];
Expand All @@ -127,18 +127,18 @@ public void PerformanceAnalysis_UPDATE_Test()
fbCommand.ExecuteNonQuery();

var dbInfo = new FbDatabaseInfo(Connection);
IDictionary<short, ulong> insertCount = dbInfo.GetInsertCount();
IDictionary<short, ulong> updateCount = dbInfo.GetUpdateCount();
IDictionary<short, ulong> readSeqCount = dbInfo.GetReadSeqCount();
IDictionary<short, ulong> readIdxCount = dbInfo.GetReadIdxCount();
var insertCount = await dbInfo.GetInsertCountAsync();
var updateCount = await dbInfo.GetUpdateCountAsync();
var readSeqCount = await dbInfo.GetReadSeqCountAsync();
var readIdxCount = await dbInfo.GetReadIdxCountAsync();

fbCommand.CommandText = "UPDATE TEST SET SMALLINT_FIELD = 900 WHERE (INT_FIELD = 900)";
fbCommand.ExecuteNonQuery();
await fbCommand.ExecuteNonQueryAsync();

insertCount = GetAffectedTables(insertCount, dbInfo.GetInsertCount());
updateCount = GetAffectedTables(updateCount, dbInfo.GetUpdateCount());
readSeqCount = GetAffectedTables(readSeqCount, dbInfo.GetReadSeqCount());
readIdxCount = GetAffectedTables(readIdxCount, dbInfo.GetReadIdxCount());
insertCount = GetAffectedTables(insertCount, await dbInfo.GetInsertCountAsync());
updateCount = GetAffectedTables(updateCount, await dbInfo.GetUpdateCountAsync());
readSeqCount = GetAffectedTables(readSeqCount, await dbInfo.GetReadSeqCountAsync());
readIdxCount = GetAffectedTables(readIdxCount, await dbInfo.GetReadIdxCountAsync());

Assert.That(insertCount.ContainsKey(tableIdTest), Is.False);
Assert.That(updateCount.ContainsKey(tableIdTest), Is.True);
Expand All @@ -157,7 +157,9 @@ private IDictionary<short, ulong> GetAffectedTables(IDictionary<short, ulong> aS
{
ulong counter = keyValuePair.Value - value;
if (counter > 0)
{
result.Add(keyValuePair.Key, counter);
}
}
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add }/{ for consistency sake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not look like it's here.

result.Add(keyValuePair.Key, keyValuePair.Value);
Expand Down