Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 76
Correction of the return values of the DatabaseInfo methods for determining the insert, read and delete operations#1183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b492ccec39be071fd24649112e28c00d785124e5f3c43a1bf72ed318aa0d9f72acda4a7edc7ee367af06600fb373f1e72ca9311a0cef7087e720df4bf09d5afa0f53c9470f22187ab1cfe4c525File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -16,6 +16,7 @@ | ||
| //$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net) | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
| using System.Threading; | ||
| @@ -61,4 +62,124 @@ public void CompleteDatabaseInfoTest() | ||
| Assert.DoesNotThrowAsync(() => (Task)m.Invoke(dbInfo, new object[] { CancellationToken.None }), m.Name); | ||
| } | ||
| } | ||
| [Test] | ||
| public async Task PerformanceAnalysis_SELECT_Test() | ||
| { | ||
| var tableNameList = await GetTableNameList(); | ||
| var tableIdTest = tableNameList["TEST"]; | ||
| var dbInfo = new FbDatabaseInfo(Connection); | ||
| 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); | ||
| var maxIntField = await fbCommand.ExecuteScalarAsync() as int?; | ||
| insertCount = await GetAffectedTables(insertCount, await dbInfo.GetInsertCountAsync()); | ||
| updateCount = await GetAffectedTables(updateCount, await dbInfo.GetUpdateCountAsync()); | ||
| readSeqCount = await GetAffectedTables(readSeqCount, await dbInfo.GetReadSeqCountAsync()); | ||
| readIdxCount = await GetAffectedTables(readIdxCount, await dbInfo.GetReadIdxCountAsync()); | ||
| Assert.That(insertCount.ContainsKey(tableIdTest), Is.False); | ||
| Assert.That(updateCount.ContainsKey(tableIdTest), Is.False); | ||
| Assert.That(readSeqCount.ContainsKey(tableIdTest), Is.True); | ||
| Assert.That(readSeqCount[tableIdTest], Is.EqualTo(maxIntField + 1)); | ||
| Assert.That(readIdxCount.ContainsKey(tableIdTest), Is.False); | ||
| } | ||
| [Test] | ||
| public async Task PerformanceAnalysis_INSERT_Test() | ||
| { | ||
| var tableNameList = await GetTableNameList(); | ||
| var tableIdTest = tableNameList["TEST"]; | ||
| var dbInfo = new FbDatabaseInfo(Connection); | ||
| 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); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not look like it's here. | ||
| await fbCommand.ExecuteNonQueryAsync(); | ||
| insertCount = await GetAffectedTables(insertCount, await dbInfo.GetInsertCountAsync()); | ||
| updateCount = await GetAffectedTables(updateCount, await dbInfo.GetUpdateCountAsync()); | ||
| readSeqCount = await GetAffectedTables(readSeqCount, await dbInfo.GetReadSeqCountAsync()); | ||
| readIdxCount = await GetAffectedTables(readIdxCount, await dbInfo.GetReadIdxCountAsync()); | ||
| Assert.That(insertCount.ContainsKey(tableIdTest), Is.True); | ||
| Assert.That(insertCount[tableIdTest], Is.EqualTo(1)); | ||
| Assert.That(updateCount.ContainsKey(tableIdTest), Is.False); | ||
| Assert.That(readSeqCount.ContainsKey(tableIdTest), Is.False); | ||
| Assert.That(readIdxCount.ContainsKey(tableIdTest), Is.False); | ||
| } | ||
| [Test] | ||
| public async Task PerformanceAnalysis_UPDATE_Test() | ||
| { | ||
| var tableNameList = await GetTableNameList(); | ||
| var tableIdTest = tableNameList["TEST"]; | ||
| var fbCommand = new FbCommand("INSERT INTO TEST (INT_FIELD) VALUES (900)", Connection); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not look like it's here. | ||
| await fbCommand.ExecuteNonQueryAsync(); | ||
| var dbInfo = new FbDatabaseInfo(Connection); | ||
| 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)"; | ||
| await fbCommand.ExecuteNonQueryAsync(); | ||
| insertCount = await GetAffectedTables(insertCount, await dbInfo.GetInsertCountAsync()); | ||
| updateCount = await GetAffectedTables(updateCount, await dbInfo.GetUpdateCountAsync()); | ||
| readSeqCount = await GetAffectedTables(readSeqCount, await dbInfo.GetReadSeqCountAsync()); | ||
| readIdxCount = await GetAffectedTables(readIdxCount, await dbInfo.GetReadIdxCountAsync()); | ||
| Assert.That(insertCount.ContainsKey(tableIdTest), Is.False); | ||
| Assert.That(updateCount.ContainsKey(tableIdTest), Is.True); | ||
| Assert.That(updateCount[tableIdTest], Is.EqualTo(1)); | ||
| Assert.That(readSeqCount.ContainsKey(tableIdTest), Is.False); | ||
| Assert.That(readIdxCount.ContainsKey(tableIdTest), Is.True); | ||
| Assert.That(readIdxCount[tableIdTest], Is.EqualTo(1)); | ||
| } | ||
| async Task<IDictionary<short, ulong>> GetAffectedTables(IDictionary<short, ulong> statisticInfoBefore, IDictionary<short, ulong> statisticInfoAfter) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why Task? | ||
| { | ||
| var result = new Dictionary<short, ulong>(); | ||
| foreach (var keyValuePair in statisticInfoAfter) | ||
| { | ||
| if (statisticInfoBefore.TryGetValue(keyValuePair.Key, out var value)) | ||
| { | ||
| var counter = keyValuePair.Value - value; | ||
| if (counter > 0) | ||
| { | ||
| result.Add(keyValuePair.Key, counter); | ||
| } | ||
| } | ||
| else | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done Member There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
| return await Task.FromResult(result); | ||
| } | ||
| async Task<IDictionary<string, short>> GetTableNameList() | ||
| { | ||
| IDictionary<string, short> result = new Dictionary<string, short>(); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not look like it's here. | ||
| await using (var command = new FbCommand("select R.RDB$RELATION_ID, TRIM(R.RDB$RELATION_NAME) from RDB$RELATIONS R WHERE RDB$SYSTEM_FLAG = 0", Connection)) | ||
| { | ||
| await using (var reader = await command.ExecuteReaderAsync()) | ||
| { | ||
| while (await reader.ReadAsync()) | ||
| { | ||
| result.Add(reader.GetString(1), reader.GetInt16(0)); | ||
| } | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await usingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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.