This tag is for questions about using timers in code to make things happen in a certain order or for gathering amount of time elapsed.

learn more… | top users | synonyms

1
vote
2answers
48 views

Lower the volume of my computer over time in Python

I wrote a program to gradually lower the volume of my computer when I go to sleep so I can fall asleep with TV or music on. This was my first time using argparse and I feel like there should be a ...
2
votes
1answer
42 views

Custom countdown second timer

I'm making a card game and I found useful to include a 60 second countdown timer. Here is my approach: ...
1
vote
0answers
49 views

Restarting properly

I have an activity with a timer in it, which starts an activity when the timer goes down. Before, when onPause() would get called after a phone call, my activity ...
1
vote
0answers
47 views

Millisecond timer using plain standard C++98

For development I'm using timer classes that are based on Win32 functions like QueryPerformanceCounter() or the time stamp counter of Intel-compatible CPUs. ...
3
votes
2answers
108 views

setTimeout and setInterval

Problem statement After 10 sec of execution of a program, start reading the property descriptors of each property of an object and continue reading all remaining properties each, every 3 ...
5
votes
1answer
110 views

Minimalist countdown timer with C#

I'm looking to add a module to one of my utility classes that functions as a countdown timer for tools that execute tasks after a certain amount of time. The code below is what I have working for PoC, ...
3
votes
0answers
23 views

Periodically monitor if record is not updated using Node, Event and setTimeOut

Here is my scenario: Every user checks in every five minutes. If some user doesn't check in after 5 minutes, I should be able to keep track of it. If some user doesn't check in N number of times, an ...
12
votes
4answers
924 views

Rubik's cube timer & scrambler

This uses a linked list to store the data. I used a linked list as it's the only type of data structure that I know currently. Using chrono, I can get microseconds ...
3
votes
0answers
36 views

Precise timings with low jitter via RDTSC (for x86 and x64)

The Win32 API has a so-called 'high performance counter' (QueryPerformanceCounter() and friends) but often it is neither precise enough nor reliable enough, due to ...
0
votes
2answers
40 views

Executing periodic tasks

I am writing a code in Golang to execute a periodic function (every 2 second). According to documentation and an example I have written two programs. Can anybody tell which one is better? Also, is ...
3
votes
2answers
62 views

Pomodoro Timer in Javascript

I've made a Pomodoro Timer application. All it does is countdown from a time in minutes given by the user to 0:00. It does this first for a session time, and then switches to a break timer and ...
3
votes
1answer
136 views

sleep() function [closed]

I wrote a sleep() function in C, but I don't know is it harmless and cross-platform. Here its code: ...
7
votes
3answers
472 views

Measuring performance of code using StopWatch

I have created a StopWatch class to measure the performance of any code. I use this StopWatch code in any of my multithreading projects as well. ...
12
votes
4answers
151 views

Simple stopwatch class

I'm not sure what the best way is when dealing with users calling start() multiple times or stop() before calling ...
2
votes
2answers
148 views

Writing C#'s analog of setTimeout, setInterval and clearInterval

I got tired of starting timer every time I need to do something simple as running some function 5 seconds after something in my code happens. So I tried to write a function (actually, 3 of them: ...
7
votes
3answers
340 views

Egg timer in Bash

I just started to learn programming, going through a lot of different tutorials, trying out different programming languages and I stumble in the same sort of questions all over the place. I give you ...
3
votes
0answers
42 views

A version of the Pebble Big Time watch face that also displays the date

I'm seeking style pointers, bugs, memory leaks, incorrect usage etc. ...
2
votes
1answer
46 views

MyTimer based on QTimer

I needed a timer that fires in intervals for a given duration when e.g. a button is pressed. The button can be pressed several times thus I thought it would be easiest to create a new timer for each ...
6
votes
1answer
69 views

Rate limiting function calls

I wanted to write a function that when applied to another would rate limit it, but permit all calls to eventually make it through. Comments and criticism welcome. ...
14
votes
3answers
564 views

“Ticker” for game timing

I designed a "Ticker" based on how I imagine Minecraft's tick system works. My ticker calls a method tickRate times a second and provides a Delta Time value (...
6
votes
1answer
87 views

Timer in pure JavaScript

I was working on a timer code in pure JavaScript and would like to know any pointers to improve: Features Start/ Stop/ Reset on click of a button. Set limit to clock. Update class name for warning ...
4
votes
2answers
97 views

Auctioneer calling “Going once… going twice… sold!”

I feel like the if-else combination isn't the most optimal and I'm also not sure if I need a loop ...
0
votes
1answer
135 views

Case of System.Timers.Timer vs System.Threading.Timer

I have a console application that I want to use to send an email notification every day at some time (call it 06:00 local time). To do so at the moment I am using a ...
2
votes
3answers
98 views

Simple JavaScript timer function

I've written a timer to start when the page loads, and to stop when the user clicks a "finished" button: ...
2
votes
0answers
55 views

Pomodoro Timer via setTimeout()

I've made my attempt to code timer entirely by hand using jQuery. No external libraries to manage time at all. ...
4
votes
1answer
119 views

Creating a Tomato Timer

I have completed a FreeCodeCamp exercise to create a tomato timer and chosen to do so with vanilla Javascript. Although it works, I don't like in how many places I am checking against two state ...
3
votes
1answer
57 views

Javascript: timer function

This is a function I made for a timer that counts down and performs a callback at the end. It seems to work fine, but I think the code is not very clean and has some unnecessary bits; also I would ...
3
votes
1answer
83 views

Ability System in my game

I'm writing a game in C# Monogame, and I've decided to make my project as modular as possible. GitHub At first, I've had a single project with a folder that's separated inside to other folders ...
6
votes
1answer
114 views

Task Reminder - Repeatedly notify every 6 hours

So I'm very much a beginner to Java and Android programming. I've worked a lot more with Python so I might have some quirks from there bleeding into my code here. I'd like a particular focus on ...
4
votes
1answer
954 views

Pomodoro Timer via setInterval

I'm hoping for some input on if my code is DRY or how I could have made it more efficient. I am pretty new in terms of jQ/JavaScript and this took me far longer than I care to admit. I will post the ...
6
votes
1answer
67 views

Creating an in-memory ViewCounter that commits to database every 10 minutes

This singleton is responsible for counting every pageview (called Routes in our case) we get by id, until the timer runs out and commits the results to the database in one query. Then the counter gets ...
11
votes
2answers
167 views

A low tech approach to measuring game speed

Whilst developing a game I needed a delay routine capable of doing delays ranging from 0.5 sec to just a few msec. The obvious choice was to use the BIOS delay function 86h on int 15h. In a true real ...
2
votes
1answer
102 views

Is a Timer the best way to achieve recursive in Android?

I'm changing the Viewpager items programmatically using mViewPager.setCurrentItem(position); with a regular interval of time recursively. Please tell me if this is ...
4
votes
1answer
61 views

Time spend in scoped timer

I want to check some timing of my (pre-C11) C++ and wrote a class: ...
4
votes
3answers
426 views

Debounce in Scala

This is my attempt at implementing debounce in Scala without any 3rd party library. How can I improve the code/make it more idiomatic (and any bugs I might have missed)? ...
5
votes
1answer
69 views

Abstracting test suite for simple performance evaluation in Java

Today, I sat down to write a tiny performance test to quickly assess a hunch I had regarding an optimization. The resulting code eventually got rather large for my taste; thus I subsequently tried to ...
7
votes
1answer
115 views

Portable method of getting time in C

Mac doesn't have the Unix clock_gettime so I am trying to create something that's really portable and only dependent on C. So far I've come across this function: ...
2
votes
1answer
115 views

Hash table with “Time To Live” elements

Recently, I got a very interesting task: to realize the hash table that works in multi-process server in common memory, each element of which must have a TTL property. It was suggested to implement ...
3
votes
1answer
6k views

Countdown timer in PHP

Using PHP and jQuery, I was able to make this countdown timer. I've searched various books and obviously on Google, but couldn't find this type of approach as used by me here. I sincerely feel there ...
3
votes
1answer
3k views

Proper use of timer in windows service

I have following code to use timer (System.Timers.Timer) in windows service. The goal is that new time handler should not occur if previous one didn't finish its job. Here is how I achieve this: ...
14
votes
2answers
175 views

A Nightmare on setTimeout Street

I have script which plays audio, shows/hides elements: ...
2
votes
1answer
114 views

Reimplementation of Underscore _.throttle

I've built a function that mimics _.throttle (returns a new, throttled version of the passed function, that, when invoked repeatedly, will only actually call the original function at most once per ...
2
votes
1answer
77 views

Running alarms in python

My code is designed to simply trigger alarms; it is not supposed to be used by anyone but me. ...
2
votes
2answers
99 views

Countdown to multiple update times each day

I'm creating an update function to show my users when the next update will be available. I'm using the jQuery countdown plugin to show the time. What is a more efficient way to write this? ...
2
votes
3answers
2k views

Timer stop watch in AngularJS

I wrote a script for a timer. Is there any way to improve the code, with fewer number of lines? JSBIN ...
3
votes
1answer
302 views

Full screen countdown display

As a part of a bigger application, I wrote code which creates a display for a countdown of a given time. It is nothing fancy, but I would still appreciate a review. I am especially concerned about: ...
7
votes
2answers
373 views

Simple 3…2…1 countdown in iOS app

I would like to display a 3...2...1 countdown on my iOS app (before to take a picture) but I didn't find an elegant solution. I don't want to make a Countdown app with an NSTimer. For me the important ...
3
votes
3answers
89 views

Functions between certain times of the day

I'm working on something for my school's laptops that will disable videos/games between 8:00 AM and 3:15 PM. Due to the giant time gap, I will not be waiting to see if the code functions properly or ...
6
votes
1answer
323 views

A thread-safe stop watch utility class

I am writing a stop watch utility class in Java that I want to be thread-safe (concurrent). Here is what I have right now: ...
0
votes
1answer
265 views

Timers to use various Task(s)

I am developing a C# program, which performs various tasks in parallel threads. I created a Base task and let all tasks derived from this class execute. I just want to know if this a viable approach ...