I know for the fact that ExecuteQuerySegmented runs the query against the Azure Table Storage. I would like to know on how can I output the download speed when ExecuteQuerySegmented is called? Something like:
var queryResult = table.ExecuteQuerySegmented(new TableQuery<TModel>(), token);
//a decimal or double value below this line to get the download speed after the call to ExecuteQuerySegmented is executed.
Any suggestions would be appreciated.
As far as I know, we could not directly get the download speed of the ExecuteQuerySegmented is called.
Here is a workaround, we could get the average download speed of the ExecuteQuerySegmented.
We could use "System.Diagnostics.Stopwatch" class to get the execution time of table.ExecuteQuerySegmented method and use "System.Text.Encoding.Unicode.GetByteCount(Since the response of the azure storage using json format to generate the result) to get the result's size of the "table.ExecuteQuerySegmented".
At last, we could calculate the speed by using bytes/second.
More details, you could refer to below codes:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
"yourstorageaccount");
// Create the table client.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// Retrieve a reference to the table.
CloudTable table = tableClient.GetTableReference("tablename");
string filter = TableQuery.GenerateFilterCondition(
"PartitionKey", QueryComparisons.Equal, "Aut");
TableContinuationToken continuationToken = null;
TableQuery<BookTest3> query = new TableQuery<BookTest3>().Where(filter);
var watch = System.Diagnostics.Stopwatch.StartNew();
var queryResult = table.ExecuteQuerySegmented(query, continuationToken).Results;
watch.Stop();
//get the execute time
float seconds = watch.ElapsedMilliseconds/ 1000;
//Serialize the object
string s = JsonConvert.SerializeObject(queryResult);
//get bytes
float re = System.Text.Encoding.Unicode.GetByteCount(s)/1000;
Console.WriteLine(re/seconds);
Console.Read();