Linked Questions

87 votes
4 answers
118k views

Obviously I can do and DateTime.Now.After - DateTime.Now.Before but there must be something more sophisticated. Any tips appreciated.
Ian G's user avatar
  • 30.3k
69 votes
5 answers
43k views

Possible Duplicates: Is DateTime.Now the best way to measure a function's performance? Stopwatch vs. using System.DateTime.Now for timing events I have code which needs to run as fast as ...
Ahmet Altun's user avatar
  • 4,059
16 votes
4 answers
41k views

I have got the following code: DateTime start = DateTime.Now; Thread.Sleep(60000); DateTime end = DateTime.Now; and I would like to calculate the difference in minutes between start and end. How am I ...
P Sawicki's user avatar
  • 219
7 votes
3 answers
20k views

i like to set timer for calculating execution time in c# for particular process in my execution. how can i do this
ratty's user avatar
  • 13.5k
1 vote
2 answers
1k views

I was trying to "benchmark" two nearly identical loops. When I inspect them one by one the subtraction is without any hiccups, and the TimeSpan gives back the correct numbers as the TotalMilliseconds. ...
masm64's user avatar
  • 1,292
1 vote
1 answer
933 views

We are working on two different libraries which tends to perform the same work. I have been assigned to check which library performs the same work faster with given set of inputs. there are multiple ...
AzeemSheikh's user avatar
3 votes
1 answer
1k views

I have a select query, i would like to run it 50 times in parallel(to load test) ie. 50 independent times(a separate process). if i run like this for (int i=0;i<=49;i++) { //record start time ...
Sharpeye500's user avatar
  • 9,117
-2 votes
4 answers
154 views

I have this code: var userId = Int32.Parse(User.Identity.GetUserId()); using (var context = new IdentityContext()) { roleId = context.Database.SqlQuery<int>("SELECT RoleId FROM ...
Samantha J T Star's user avatar
0 votes
2 answers
59 views

I would like to test the time required by certain methods and SQL queries in my code. I've tried doing the following: DateTime start = DateTime.Now; //Do something DateTime end = DateTime.Now; ...
PaulG's user avatar
  • 7,142
2182 votes
20 answers
756k views

How do I find areas of my code that run slowly in a C++ application running on Linux?
Gabriel Isenberg's user avatar
743 votes
9 answers
777k views

I have an I/O time-taking method which copies data from a location to another. What's the best and most real way of calculating the execution time? Thread? Timer? Stopwatch? Any other solution? I want ...
Mahdi Tahsildari's user avatar
510 votes
6 answers
462k views

Using LINQ on collections, what is the difference between the following lines of code? if(!coll.Any(i => i.Value)) and if(!coll.Exists(i => i.Value)) When I disassemble .Exists, it looks like ...
Anthony D's user avatar
  • 11.3k
148 votes
7 answers
198k views

I want to know how much time a procedure/function/order takes to finish, for testing purposes. This is what I did, but my method is wrong, because if the difference of seconds is 0, it can't return ...
ElektroStudios's user avatar
79 votes
14 answers
94k views

Is it ever OK to use Environment.TickCount to calculate time spans? int start = Environment.TickCount; // Do stuff int duration = Environment.TickCount - start; Console.WriteLine("That took "...
user avatar
52 votes
18 answers
30k views

I'm doing some real quick and dirty benchmarking on a single line of C# code using DateTime: long lStart = DateTime.Now.Ticks; // do something long lFinish = DateTime.Now.Ticks; The problem is in the ...
Scott Marlowe's user avatar

15 30 50 per page