Questions tagged [stopwatch]

The System.Diagnostics.Stopwatch class in .Net, used to accurately measure elapsed time.

837 questions
4
votes
1 answer

C# Looking for a thread safe and effective way to capture elapsed time across multiple namespaces

We are beginning capture measurements of time to execute specific tasks throughout our code. Using the Stopwatch class is getting the job done, but the concern is that Stopwatch is effective for measuring time within a single function, or block of…
Jason P
  • 66
  • 3
4
votes
1 answer

Measure precision of timer (e.g. Stopwatch/QueryPerformanceCounter)

Given that the Stopwatch class in C# can use something like three different timers underneath e.g. System timer e.g. precision of approx +-10 ms depending on timer resolution that can be set with timeBeginPeriod it can be approx +-1 ms. Time Stamp…
nietras
  • 3,949
  • 1
  • 34
  • 38
4
votes
1 answer

stopwatch time per user in c# asp.net mvc application

I have a set of users in my asp.net mvc application. When any user start stopwatch then i need stopwatch to continue even after user logout. And run it until he does not login again and click stop. i can start it on start button click …
kakon
  • 701
  • 6
  • 18
4
votes
1 answer

Stopwatch and DateTime.UtcNow producing unexpectedly large timing variations

We have application logs that record performance information for various expensive operations. We use both Stopwatch and DateTime.UtcNow in our logging, and we are finding that these values can differ MUCH more than would be expected, even given…
ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
4
votes
6 answers

How would I go about implementing a stopwatch with different speeds?

Ideally I would like to have something similar to the Stopwatch class but with an extra property called Speed which would determine how quickly the timer changes minutes. I am not quite sure how I would go about implementing this. Edit Since people…
James
  • 80,725
  • 18
  • 167
  • 237
4
votes
1 answer

Performance of signaling threads in c#

I've been attempting to understand how long it takes to "wake" a thread who is waiting on a blocking construct like AutoResetEvent- from what I understood after reading multiple discussions is that windows has some kind of internal clock which…
Tomer Arazy
  • 1,833
  • 10
  • 15
4
votes
2 answers

Different values of Stopwatch.Frequency on the same PC

I'm working on online game and have client and server. For client I use Unity3D and C#, server is written in C#. For synchronization I use timers, and as we know timers depends from ticks. Ticks counter in C# is class Stopwatch, and count of ticks…
user2686299
  • 427
  • 8
  • 25
4
votes
4 answers

C# *Strange* problem with StopWatch and a foreach loop

I have the this code: var options = GetOptions(From, Value, SelectedValue); var stopWatch = System.Diagnostics.Stopwatch.StartNew(); foreach (Option option in options) { stringBuilder.Append("
Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288
4
votes
4 answers

how to stop stopwatch during debugging C# and vs2012

So i have some code that depends upon stopwatch for some calculations. However once stopwatch starts it doesn't stop even during debugging and it is creating problems for me when i try to debug the code. Is there any way that i can stop stopwatch…
Win Coder
  • 6,628
  • 11
  • 54
  • 81
4
votes
3 answers

StopWatch Loop using VB.NET

I want to create a simple timer with this interface using VB.NET I want to press Button1 and to start counting seconds in the textbox. I do not want to use the Timer Component because it does not offer high resolution. So, I decided to use a…
Novemberland
  • 530
  • 3
  • 8
  • 25
4
votes
1 answer

Event timer delayed in .NET not in Mono. Is it a bug?

DotNet alternative (MONO-http://www.go-mono.com/mono-downloads/download.html) handles the short timer condition properly (down to ~12 ms firing time) Yet, DotNet appears to take longer then expected and "Misses". So, which behavior is correct? Does…
PizzaRoll
  • 71
  • 6
4
votes
2 answers

Does it take some time to start and stop Stopwatch?

I have a very specific question that I need answered for a very specific performance test. I will simplify the code, to make it easier understandable. I do many calculations (a few ten million), all done in loops that are themselves not too long and…
philkark
  • 2,417
  • 7
  • 38
  • 59
4
votes
1 answer

Using a stopwatch to benchmark application usage

Hi I am trying to make a global class that I can use in my projects, I intend to use this as my default template, I am a newbie so please be patient ;) Stopwatch Masterstopwatch = new Stopwatch(); #if DEBUG private static void…
user1388425
  • 117
  • 2
  • 8
4
votes
3 answers

How do I create a stopwatch Bash script to constantly display elapsed time?

You can think of this like a really simple stopwatch. I'm trying to hack together a bash script that displays the elapsed time since a specified date and updates the output every second. First, Inside the script you'd specify a UNIX date: Fri Apr…
jerzy
  • 2,364
  • 4
  • 20
  • 24
3
votes
2 answers

Synchronizing Forms.Timer and Diagnostics.Stopwatch

I have a function (say foo())that will be called from time to time with a variable interval. When it is called, it checks the time and takes an action accordingly. I have done this in the following way: A Forms.Timer object invokes the function…
Hayri Uğur Koltuk
  • 2,970
  • 4
  • 31
  • 60