Questions tagged [timing]

timing is a numerical measurement of the how long it takes to execute an instruction or series of instructions

Timing is a numerical measurement of the how long it takes to execute an instruction or series of instructions. See also .

To get a better understanding of performance of a given code, it should be measured at several problem sizes and empirical orders of growth calculated.

1396 questions
1012
votes
42 answers

How do I time a method's execution in Java?

How do I get a method's execution time? Is there a Timer utility class for things like timing how long a task takes, etc? Most of the searches on Google return results for timers that schedule threads and tasks, which is not what I want.
Ogre Psalm33
  • 21,366
  • 16
  • 74
  • 92
152
votes
14 answers

What is the Python equivalent of Matlab's tic and toc functions?

What is the Python equivalent of Matlab's tic and toc functions?
Alex
  • 2,145
  • 3
  • 19
  • 19
146
votes
9 answers

Hide div after a few seconds

I was wondering, how in jquery am I able to hide a div after a few seconds? Like Gmail's messages for example. I've tried my best but am unable to get it working.
James
  • 5,942
  • 15
  • 48
  • 72
127
votes
5 answers

How to enable build timing in Xcode?

I'd like to know how long my project's builds take, for example by displaying it in the build pane. Is this option available somewhere in Xcode? Thanks.
Guillaume
  • 4,901
  • 5
  • 24
  • 19
114
votes
9 answers

timeit versus timing decorator

I'm trying to time some code. First I used a timing decorator: #!/usr/bin/env python import time from itertools import izip from random import shuffle def timing_val(func): def wrapper(*arg, **kw): '''source:…
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
106
votes
3 answers

Stopwatch vs. using System.DateTime.Now for timing events

I wanted to track the performance of my code so I stored the start and end time using System.DateTime.Now. I took the difference between the two as the time my code to execute. I noticed though that the difference didn't appear to be accurate. So I…
Randy Minder
  • 47,200
  • 49
  • 204
  • 358
103
votes
3 answers

Get execution time of PostgreSQL query

DECLARE @StartTime datetime,@EndTime datetime SELECT @StartTime=GETDATE() select distinct born_on.name from born_on,died_on where (FLOOR(('2012-01-30'-born_on.DOB)/365.25) <= ( select max(FLOOR((died_on.DOD - born_on.DOB)/365.25)) from …
user425243
101
votes
13 answers

How to make `setInterval` behave more in sync, or how to use `setTimeout` instead?

I am working on a music program that requires multiple JavaScript elements to be in sync with another. I’ve been using setInterval, which works really well initially. However, over time the elements gradually become out of sync which is bad in a…
user3084366
  • 1,103
  • 2
  • 9
  • 12
90
votes
8 answers

Is it possible to get a history of queries made in postgres

Is it possible to get a history of queries made in postgres? and is it be possible to get the time it took for each query? I'm currently trying to identify slow queries in the application I'm working on. I'm using Postgres 8.3.5
Chiwai Chan
  • 4,716
  • 4
  • 30
  • 33
89
votes
6 answers

Best timing method in C?

What is the best way to time a code section with high resolution and portability? /* Time from here */ ProcessIntenseFunction(); /* to here. */ printf("Time taken %d seconds %d milliseconds", sec, msec); Is there a standard library that would have…
lillq
  • 14,758
  • 20
  • 53
  • 58
84
votes
6 answers

How do I measure duration in seconds in a shell script?

I wish to find out how long an operation takes in a Linux shell script. How can I do this?
yazz.com
  • 57,320
  • 66
  • 234
  • 385
78
votes
4 answers

Python class @property: use setter but evade getter?

In python classes, the @property is a nice decorator that avoids using explicit setter and getter functions. However, it comes at a cost of an overhead 2-5 times that of a "classical" class function. In my case, this is quite OK in the case of…
Jonas Lindeløv
  • 5,442
  • 6
  • 31
  • 54
67
votes
5 answers

Timing algorithm: clock() vs time() in C++

For timing an algorithm (approximately in ms), which of these two approaches is better: clock_t start = clock(); algorithm(); clock_t end = clock(); double time = (double) (end-start) / CLOCKS_PER_SEC * 1000.0; Or, time_t start =…
blaze
  • 2,588
  • 3
  • 32
  • 47
63
votes
14 answers

Schedule a repeating event in Python 3

I'm trying to schedule a repeating event to run every minute in Python 3. I've seen class sched.scheduler but I'm wondering if there's another way to do it. I've heard mentions I could use multiple threads for this, which I wouldn't mind doing. I'm…
Humphrey Bogart
  • 7,423
  • 14
  • 52
  • 59
57
votes
4 answers

Is setTimeout with no delay the same as executing the function instantly?

I am looking at some existing code in a web application. I saw this: window.setTimeout(function () { ... }) Is this the same as just executing the function content right away?
Aishwar
  • 9,284
  • 10
  • 59
  • 80
1
2 3
92 93