One key aspect during performance testing is to time how long a function takes to execute. In this small post, I will show how to create a generic timing function that takes as argument the function to time and shows the time to execute along with the output of the function:
/// <summary>
/// Times the execution of a function and outputs both the elapsed time and the function's result.
/// </summary>
static void Time<T>(Func<T> work)
{
var sw = Stopwatch.StartNew();
var result = work();
Console.WriteLine(sw.Elapsed + ": " + result);
}
To call the time, use the following invocation style:
Time(() => DoSomeWork());
Splendid blog post. I might want to pass on thank you for moving and significant data and I like your purpose of investigation. Much obliged to you! I want to comprehend writing this kind of matter great and eye-getting data I procure from this website. Much obliged to you for posting such a fine bit of writing.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for the topic. I found useful information for myself. I want to share HandmadeWriting there is also a lot of useful information.
ReplyDeleteThe technical skills and expertise the team web designer in San Francisco has dedicated to the work has saved the client valuable time
ReplyDeleteExpert project management and a solutions-oriented approach highlight their work.
ReplyDeletetop creative agency
We valued that their team continually challenged us to improve our approach.
ReplyDeletemobile app design service
They're very process and detail-oriented in their approach, ensuring the quality and organization of the project phases are well laid out.
ReplyDeletetop branding company
Liên hệ Aivivu, đặt vé máy bay tham khảo
ReplyDeletevé máy bay đi Mỹ giá rẻ 2021
ve may bay tu my ve vietnam
lich bay tu duc ve viet nam
có chuyến bay từ nhật về việt nam chưa
Chuyến bay từ Hàn Quốc về Việt Nam
vé máy bay từ canada về việt nam giá rẻ
khách sạn cách ly ở vân đồn
chi phí vé máy bay cho chuyên gia nước ngoài
This is one of the most important blogs that I have seen, keep it up!
ReplyDeletebest logo company
This blog is further than my expectations. Nice work guys!!!
ReplyDeletebest logo design services
Hello, this is fastidious post I actually loved reading this.
ReplyDeletecreative web design agency
I'm in no doubt coming back again to read these articles and blogs.
ReplyDeletetop website designing companies
Loved your blog page!!!The stuff that you have remarked up here is superbly wonderful and I vigorously thank you for the same...
ReplyDeleteUI UX design agency
thanks for sharing valuable info go now
ReplyDelete