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
• 12,270 points
11 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 7,680 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,260 points
337 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,260 points
81 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 18, 2018 in IoT (Internet of Things) by nirvana
• 3,040 points
159 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,260 points
23 views
0 votes
1 answer

Access Serial Ports in Windows 10 IoT App

On Windows IoT you have to use Windows.Devices.SerialCommunication namespace ...READ MORE

answered Oct 10, 2018 in IoT (Internet of Things) by anonymous2
• 4,260 points
40 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,190 points
26 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 23, 2018 in IoT (Internet of Things) by Upasana
• 7,680 points
22 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
• 7,680 points
72 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.