Questions tagged [time]

Measuring the time it takes to perform an operation. Also, questions related to obtaining the current time, calculating on times, formatting and parsing times, etc.

Measuring the time it takes to perform an operation. Also, questions related to obtaining the current time, calculating on times, formatting and parsing times, etc. See also and .

For analysis in , consider looking at the Time Series Task View.

29686 questions
8
votes
4 answers

Explain why this binary tree traversal algorithm has O(NlogN) time complexity?

I'm going through the Cracking the Coding Interview book right now and I'm doing a binary tree exercise. There is a snippet of code that is according to the book O(NlogN), however, I don't understand why that is. I can understand if the algorithm…
Jessica
  • 1,083
  • 2
  • 12
  • 27
8
votes
1 answer

How to create a new Date object without the year parameter in Java?

I am trying to use new SimpleDateFormat to parse a string in the format dd-MM. Basically, I want to create a date object out of the string and persist in the database. When I checked the database entry I see that it appends 1970 to the year column.…
Boudhayan Dev
  • 970
  • 4
  • 14
  • 42
8
votes
3 answers

R - Running time by line of code in dplyr

When I want to estimate the running time of a R code, I use the function system.time(). library(dplyr) system.time({ Titanic %>% as.data.frame() %>% mutate(Dataset = 1) %>% bind_rows(as.data.frame(Titanic)) %>% …
demarsylvain
  • 2,103
  • 2
  • 14
  • 33
8
votes
1 answer

How to get execution time of c program?

I am using clock function for my c program to print execution time of current program.I am getting wrong time in output.I want to display time in seconds,milliseconds and microseconds. #include #include #include int…
raj123
  • 564
  • 2
  • 10
  • 27
8
votes
1 answer

flutter - DateTime.now() not same in my local time

I have a case to check the store opening-closed hours. Im solve this using the code below: final _openHours = 09; final _openMinute = 00; final _closeHours = 15; final _closeMinute = 00; var now = DateTime.now(); print(now); var _open = new…
Kitereative Indonesia
  • 1,097
  • 6
  • 19
  • 39
8
votes
2 answers

Add a Timeout for getchar()

I need to add a timeout function for getchar() in my program. What do I do so that when my program reaches the instruction getchar(), it will only wait for a certain amount of time for the user to make a keystroke and if the user does not make a…
brain56
  • 2,659
  • 9
  • 38
  • 70
8
votes
4 answers

Current microsecond time in C?

How can I print current microseconds time in C on Unix platform?
Sachin
  • 20,805
  • 32
  • 86
  • 99
8
votes
3 answers

Python sleep without interfering with script?

Hey I need to know how to sleep in Python without interfering with the current script. I've tried using time.sleep() but it makes the entire script sleep. Like for example import time def func1(): func2() print("Do stuff here") def…
AustinM
  • 773
  • 6
  • 18
  • 27
8
votes
7 answers

How to display updated time as system time on a label using c#?

I want to display current time on a label using C# but time will continuously change as system time changes. How can I do this?
Akshay
  • 119
  • 2
  • 2
  • 4
8
votes
9 answers

How do I handle date and time in different time zone?

I'm developing an international software that act as a simple project management software and I'm facing a problem. This problem is about date/hour and time zone. When a message is sent from one time zone to another time zone I can store the UTC…
Guillaume
  • 759
  • 1
  • 9
  • 21
8
votes
4 answers

Making cProf give only the 10 most time-consuming tasks or sort them by time in reverse order

I'm running the following code line on my terminal to get a profile of my program. python3 -m cProfile -s time main.py However the output it prints is gigantic. I only want to know the 10 most time-consuming tasks or to sort them in ascending…
Caterina
  • 775
  • 9
  • 26
8
votes
2 answers

How long since last time app was opened in iOS?

How can I tell the time from the last time my app was open? Can this still be monitored even my app is not running in the background? Thanks.
joshim5
  • 2,292
  • 4
  • 28
  • 40
8
votes
1 answer

Does calling DateTime.AddDays with a whole number always leave the time unchanged?

Consider the following code which attempts to get a DateTime that's equivalent to the local time "midnight yesterday": DateTime midnightYesterday = DateTime.Today.AddDays(-1.0d); Will this always result in a DateTime with a time component of…
Jon Schneider
  • 25,758
  • 23
  • 142
  • 170
8
votes
2 answers

What is the fastest way to get the current time in C++11?

Context: I'm writing a high performance C++11 application, one part of it is to remove inactive connections. For that, I'm storing a "last activity" timestamp in my connection object, which I update when an action is taken. I then have a timer which…
Gediminas Masaitis
  • 3,172
  • 14
  • 35
8
votes
2 answers

How to measure time of julia program?

If I want to calculate for things in Julia invQa = ChebyExp(g->1/Q(g),0,1,5) a1Inf = ChebyExp(g->Q(g),1,10,5) invQb = ChebyExp(g->1/Qd(g),0,1,5) Qb1Inf = ChebyExp(g->Qd(g),1,10,5) How can I count the time? How many seconds do i have to wait for…