Testing your code for speed

0 votes
I'm totally new to this, but I was writing a little program that worked on strings in C# and I noticed that if I did a few things differently, the code executed significantly faster.

So it had me wondering, how do you go about clocking your code's execution speed? Are there any (free)utilities? Do you go about it the old-fashioned way with a System. Timer and do it yourself?
Nov 13, 2018 in IoT (Internet of Things) by Shubham
• 13,490 points
595 views

1 answer to this question.

0 votes

What you are describing is known as performance profiling. There are many programs you can get to do this such as JetBrains profiler or ANTS profiler, although most will slow down your application whilst in the process of measuring its performance.

To hand-roll your own performance profiling, you can use System.Diagnostics.Stopwatch and a simple Console.WriteLine, like you described.

Also, keep in mind that the C# JIT compiler optimizes code depending on the type and frequency it is called, so play around with loops of differing sizes and methods such as recursive calls to get a feel of what works best.

answered Nov 13, 2018 by Upasana
• 8,620 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

Downloading source code of Android Things

No because AndroidThings is still in preview ...READ MORE

answered Jul 5, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
1,880 views
0 votes
1 answer

What is the maximum message length for a MQTT broker?

It's not entirely clear what you're asking ...READ MORE

answered Jul 17, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
9,462 views
0 votes
1 answer

Connect Android Things based Raspberry Pi 3 to wifi network for the first time!

Hey, I think its alright!  Your Raspberry Pi ...READ MORE

answered Jul 19, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,158 views
0 votes
1 answer
0 votes
1 answer

Configuring a Windows 10 IoT App for Automatic Restart

Have you tried using powershell right after ...READ MORE

answered Oct 10, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
998 views
0 votes
1 answer

Access Serial Ports in Windows 10 IoT App

On Windows IoT you have to use ...READ MORE

answered Oct 10, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
2,164 views
0 votes
1 answer

Problem disposing of socket

If this object is eligible for garbage ...READ MORE

answered Oct 15, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
1,170 views
0 votes
1 answer

What is the time taken by a 200 byte message for transmission in a beacon-enabled network?

Now, data rates of IEEE 802.15.4 are ...READ MORE

answered Aug 24, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
888 views
0 votes
1 answer

When to use MQTT and when to use REST for event submission?

MQTT is designed to be a fast ...READ MORE

answered Sep 14, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,510 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP