in Amazon.QLDB.Driver.IntegrationTests/AsyncStatementExecutionTests.cs [477:522]
public async Task ExecuteAsync_ExecutionMetrics()
{
var insertQuery = String.Format("INSERT INTO {0} << {{'col': 1}}, {{'col': 2}}, {{'col': 3}} >>",
Constants.TableName);
await qldbDriver.Execute(async txn => await txn.Execute(insertQuery));
// Given
var selectQuery = String.Format("SELECT * FROM {0} as a, {0} as b, {0} as c, {0} as d, {0} as e, {0} as f",
Constants.TableName);
// When
await qldbDriver.Execute(async txn =>
{
var result = await txn.Execute(selectQuery);
long readIOs = 0;
long processingTime = 0;
await foreach (IIonValue row in result)
{
var ioUsage = result.GetConsumedIOs();
if (ioUsage != null)
readIOs = ioUsage.Value.ReadIOs;
var timingInfo = result.GetTimingInformation();
if (timingInfo != null)
processingTime = timingInfo.Value.ProcessingTimeMilliseconds;
}
// The 1092 value is from selectQuery, that performs self joins on a table.
Assert.AreEqual(1092, readIOs);
Assert.IsTrue(processingTime > 0);
});
// When
var result = await qldbDriver.Execute(async txn => await txn.Execute(selectQuery));
var ioUsage = result.GetConsumedIOs();
var timingInfo = result.GetTimingInformation();
Assert.IsNotNull(ioUsage);
Assert.IsNotNull(timingInfo);
// The 1092 value is from selectQuery, that performs self joins on a table.
Assert.AreEqual(1092, ioUsage?.ReadIOs);
Assert.IsTrue(timingInfo?.ProcessingTimeMilliseconds > 0);
}