Questions tagged [stopwatch]

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

837 questions
5
votes
2 answers

how to get last time interval since last split?

I want to run a stop watch form the beginning of my program and log the time split of some intervals. Which StopWatch should I prefer? import com.google.common.base.Stopwatch; org.apache.commons.lang.time.StopWatch For example: Start -----> split…
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
5
votes
5 answers

C# 2.0 Execution Time Timer

I would like to be able to calculate the amount of time a number of functions take to execute. I was thinking about using some type of stopwatch class. I can call start/stop before and after each function call, however that seems horribly ugly to…
J.Hendrix
  • 2,199
  • 4
  • 20
  • 26
5
votes
1 answer

What's causing this spike in time of string concatenation?

So out of curiosity and idle boredom, I was fooling around with benchmarking Shlemiel the painter's algorithm. I started with a blank string, created another one of 1000 blank spaces, and started adding one to the other, using plain old inefficient…
Mike G
  • 4,232
  • 9
  • 40
  • 66
5
votes
2 answers

Can't find reference to System.Diagnostics.Stopwatch

I am attempting to build a simple stopwatch WPF application. Here is my code: using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Windows; using…
jth41
  • 3,808
  • 9
  • 59
  • 109
5
votes
4 answers

Stopwatch for performance testing

For some private project I use Stopwatch for performance measurement. But on low repitition count of calls I want to measure, I end up with 0 ElapsedMilliseconds, which makes it difficult to calculate an average. I thought about writing my own…
Mare Infinitus
  • 8,024
  • 8
  • 64
  • 113
5
votes
2 answers

how to invoke a method for every second in ruby

I wanted to create a stopwatch program in ruby so I googled it and found this SO Q. But over there, the author calls the tick function with 1000xxx.times. I wanted to know how I can do it using something like (every second).times or for each…
Clone
  • 919
  • 4
  • 11
  • 22
5
votes
1 answer

Why does the conditional (ternary) operator seem significantly faster?

EDIT If I use Stopwatch correctly and up the number of iterations by two orders of magnitude I get Ternary took 22404ms Normal took 21403ms These results are closer to what I was expecting and make me feel all is right with the world (if not with…
Jodrell
  • 34,946
  • 5
  • 87
  • 124
5
votes
1 answer

Stopwatch.IsHighResolution == false on my machine. Why?

Sorry, it is always true! Edited... I've just realised that Stopwatch.IsHighResolution returns false in my machine. Why? What is needed to it return true? What kind of hardware? MSDN do not say much about that. Machine config: Win 7 x64; i7 930;…
Pedro77
  • 5,176
  • 7
  • 61
  • 91
5
votes
1 answer

Java Stopwatch that updates the GUI every second?

I'm a Java beginner and I'm trying to build a simple stopwatch program that displays the time on a swing GUI. Making the stopwatch is easy, however I cannot find a way to make the GUI update every second and display the current time on the…
Dangerosking
  • 438
  • 3
  • 12
  • 23
4
votes
1 answer

gettimeofday() C++ Inconsistency

I'm doing a project that involves comparing programming languages. I'm computing the Ackermann function. I tested Java, Python, and Ruby, and got responses between 10 and 30 milliseconds. But C++ seems to take 125 milliseconds. Is this normal,…
Noah Singer
  • 526
  • 2
  • 6
  • 17
4
votes
3 answers

Stopwatch Java API

Is there something out there that would allow me to create static object in my class or extend my class and give me functions to start, stop time configure statistics collection with properties file and bunch of other goodies I don't even know…
MatBanik
  • 26,356
  • 39
  • 116
  • 178
4
votes
2 answers

How to stop the time from running after pressing "stop" on stopwatch

I have created this stopwatch and it runs pretty well. The only problem that I am having is that whenever I click my "stop" button, the time stops on the screen but it is still running in the background. Is there any way to stop this from happening?…
John Doee
  • 207
  • 4
  • 15
4
votes
3 answers

How can I fix my Javascript stopwatch with the 00:00 time format? (Seconds:Milliseconds)

Is there any way to get this to run a stopwatch? I dont need any start or stop buttons, it should just run a stopwatch when the page loads and the stopwatch needs to keep running. I have gotten everything else to work, but I cannot find a function…
John Doee
  • 207
  • 4
  • 15
4
votes
2 answers

Stopwatch multi-task ElapsedMilliseconds calculation

I have a very basic function to track time taken by each function call. The stopwatch in UnitWorkAsync returns expected values but the timer in ParentWorkAsync keeps adding the time across tasks. What am I doing wrong with the stop watch tracking?…
Nikhil
  • 43
  • 3
4
votes
7 answers

Java high precision stopwatch

I have this problem, and I can't get any idea how to solve it. I have to measure the time needed to perform certain function. Okay, stopwatch function that measure time in milliseconds wasn't good enough, so I used measurement in nano seconds. The…
CRT_flow
  • 117
  • 2
  • 11