Questions tagged [timer]

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.

Filter by
Sorted by
Tagged with
4
votes
1answer
126 views

Scheduling using System.IObservable

With great inspiration from t3chb0ts ongoing work about scheduling, cron jobs etc. (last post here), I decided to make my own version of the Scheduler - using the observer pattern - as a learning ...
5
votes
0answers
154 views

Scheduler built with observables v2 (follow-up)

It would probably be too easy if the old Scheduler worked as intended being that simple. But an eye-openig review showed that from time to time it'll miss one ...
3
votes
1answer
4k views

Simple timer start and stop from console

Just a simple timer application for review. Stop and start the timer from the command line. The plan is to use this in a poker application to fold out a player if they don't act after a time ...
1
vote
1answer
119 views

Best accuracy and performance with timers in JS

Regular timers in JavaScript (setInteval & setTimeout) have two problems: They aren't as much accuracy as you can get in JS....
1
vote
1answer
87 views

UserScript to Highlight tab for queue item

It may seem a bit obsessive and/or pedantic, but the following script allows me to see when posts are ready for reviewing. I developed this UserScript for use with TamperMonkey to allow me to have a ...
1
vote
1answer
356 views

Multithreaded arithmetic quiz with 20-second time limit

I learned something about threads and I tried to use them in an programming exercise. The user of the program has to solve as many exercises as he can within twenty seconds. After that time the ...
3
votes
1answer
580 views

Multi-threaded Time Scheduler without polling

This is a quick shot at designing a time scheduler without polling. It is able to handle inputs which are to be executed earlier than already on the schedule. I want to improve it further, especially ...
11
votes
5answers
4k views

Stopwatch class

I am learning C# and I have an exercise: Design a class called Stopwatch. The job of this class is to simulate a stopwatch. It should provide two methods: Start and Stop. We call the start ...
31
votes
7answers
6k views

Car crash reaction time

In physics class we are doing an investigation thing. Some of the numbers might seem plucked out of thin air but they aren't. The maths is right(I think) I just want some feedback on the code. ...
4
votes
3answers
803 views

CHIP-8 delay timer in C++

I'm writing a CHIP-8 emulator in C++, which has two timers. If these timers are non-zero, they are decremented by 1 at 60Hz. I'm still getting the hang of C++, so I wanted to see if I'm doing this the ...
6
votes
1answer
241 views

Clock that changes document background color

This is a timer based clock (using setInterval()) that changes the background color of the body based on the clock time hexadecimal values. I suspect that this code ...
1
vote
1answer
760 views

Timer in JavaScript

This is my first JavaScript application (it's inspired by this timer). How could I improve it? I had to set the setInterval() to 980ms instead of 1000ms because it ...
11
votes
2answers
9k views

Progress Bar in C++

I made a simple progress bar with percentage counter for console applications in C++. Below is my code: ...
2
votes
1answer
251 views

A clock and a fortune: a full screen clock with random quotes in Tcl/Tk

I've written a small Tcl/Tk script for a friend that displays the current time, as well as a quote. He uses it in some project with a Raspberry Pi, and since I didn't want to cobble up something up in ...
4
votes
2answers
78 views

Measuring typing speed in terminal without a mistake

I tend to dislike my code. It's always a mess. I can't critique my own code though, because I just turn it into another mess. I've been programming slightly better every year, but this year it has ...
5
votes
1answer
4k views

Basic Countdown Timer

Below is a class,Countdown, that takes seconds as input from an entry, and starts counting down when the "Start" button is ...
4
votes
2answers
775 views

Countdown timer for new year

Please help me improve my code. Note that it runs just fine. Especially with the way I use SFML, I need lots of guidance since I've just started learning how to use this library. I'm still learning C++...
8
votes
1answer
263 views

Cookie Clicker Switches

In Cookie Clicker there are Golden cookies, and Wrath Golden Cookies. Golden cookies are Clickable cookies that randomly appear, and when clicked they give Bonus cookies, or temporary boosts to ...
3
votes
3answers
88 views

Date and time incrementation, using a fictional calendar / clock

I created a simple clock & calendar system using a fictional system: everything from the number of seconds in a minute, down to the number of months in a year could be different from our accepted ...
2
votes
2answers
1k views

C# Extending the DispatcherTimer - Intermission timer

I'm working on a WPF project where a timer with Pause/Resume functionality is required. The standard Windows.Threading.DispatcherTimer doesn't offer that, so I ...
2
votes
1answer
510 views

Easy used head-only timer in C++11

This timer can add tasks running for one-shot, several times, or loop every time and delete task by marking its id. It's simply implemented by a priority queue. My purpose is easy to use and ...
1
vote
0answers
38 views

Java Market Summary - JSON

I am writing a java program that will print current market values from a websites api. I used gson to parse the incoming json and Timer to run it every 5 minutes. I was wondering if this was the best ...
3
votes
1answer
1k views

A sleep primitive for CUDA device-side code

I've so far been spared the need to waste any cycles on the GPU, but it seems like this might change. After getting some information I was missing about the semantics of CUDA's ...
1
vote
1answer
230 views

Heartbeat Server

I'm writing a toy heartbeat server. Each client, upon loading, registers itself and thereafter, sends heartbeats every X seconds. The server checks every ...
4
votes
2answers
131 views

JavaScript component to display ephemeral notifications

I would like to improve my code and organization of JS files so I'm wondering if you guys could tell me what I could do better. I've included a small but typical example of how I often use components. ...
4
votes
0answers
177 views

Limit drive starts with function block diagram

I have a drive (modulating fan) which needs to be interlocked and prevented from starting. The requirement is that: The drive is limited to 3 starts per hour with a minimum of 10 minutes between ...
2
votes
1answer
148 views

Javascript timing class

I've recently came across many inconsistencies in a code which I had to maintain and develop. Mainly in ajax and timing/interval functions. I'm quite a novice in the ways of JS but tried my best to ...
8
votes
1answer
428 views

JavaScript typing speed calculator

I would like to kindly ask to review my code. I'd like suggestions, criticisms, and discussions on what is good and what could be done better. ...
3
votes
1answer
122 views

TimeoutManager: check whether a task has been finished within a given time

I want to make a helper class, which raises an event whenever something is not finished in a certain time. Example: my program sends out multiple network messages concurrently. After a random delay, ...
3
votes
2answers
3k views

Timeout implementation of fetch

After doing some research on google i didn't find any good info on how to implement timeout with fetch (looks like there are multiple proposals but that's about it so nothing has implemented it). For ...
4
votes
2answers
876 views

Constructor start, destructor end timer in C++

The following is a short timing utility I've written for a larger project that I'm working on. The larger project is designed to be called (via ffi) from a Scala/Java codebase, which makes using ...
1
vote
1answer
379 views

Timer class implementation

I have made a timer class: The timer should call an async method and wait between two calls. I want to wake up the timer to skip the wait period. When I dispose the timer from outside the timer I ...
5
votes
1answer
130 views

R function for a timer with a beep

I wrote a quick timer function that depends on the beepr package to provide the sound effect at the end of the time. I've never used a while-loop before, so I don'...
1
vote
0answers
1k views

Watchdog for multiprocessing

The code shows here is a demo of my application. The func1 always hang somewhere with reason I haven't figured out by now. Now I just want to write a watchdog for this process. If it didn't generate ...
5
votes
1answer
2k views

Simple interval timer in Python

I created a script for interval timer with tkinter gui. Here the part that is displaying time looks to be done not in the best way. Any ideas would be greatly appreciated. This timer is intended ...
2
votes
0answers
82 views

Python script to take a break

The idea may sound stupid, but this is what I got to know that you should take a break at regular intervals to not to strain your eyes. So the idea is to take break of 2 minutes for every 20 minutes ...
15
votes
1answer
2k views

Plot timings for a range of inputs

When writing Code Review answers, it becomes often necessary to measure how long the modified code takes vs how long the OP's code takes. I needed a nice way to visualize this as a function of the ...
3
votes
1answer
119 views

Pomodoro Clock JS Modularisation

I am beginner on Javascript and i made a pomodoro clock for freecodecamp project with vanilla Javascript. I was read few articles about modular and functional javascript and i want to use these ...
5
votes
2answers
188 views

small ticker class to execute a function at a regular inverval

I have written the following ticker class. You can find a description and example usage in its comments. However, it kind of feels like I am using too many thread synchronization tools (...
4
votes
1answer
82 views

Pomodoro timer module

I have been learning javascript for some time and have just finished my first piece of code that not only actually does something, but is also longer than a few lines of code. It most likely is pretty ...
3
votes
1answer
2k views

Countdown timer in React.js

Code is a countdown timer. Should I keep this update function separate as is or can I save 3 lines of code and embed ...
2
votes
0answers
868 views

A clock program in MIPS assembly that start ticking from 59:58

This is an assignment, a clock program which use MARS simulator, it starts ticking from 59:58. In this assignment I have implemented three functions ...
4
votes
1answer
5k views

Countdown timer in every table cell

I am making countdown app with multiple records, so I am using UITableView to show that records and countdown dates. What I do is just take one timer and reload cells on every second. Is this a best ...
1
vote
0answers
310 views

Pomodoro Countdown Clock

I would appreciate feedback on this Pomodoro Clock. I tried to use straight Javascript for the logic instead of JQuery and I would be interested in any observations of where that was a good or bad ...
2
votes
1answer
72 views

Detecting the end of a method chaining

I've been through a lot of posts over the web(and in SO) saying that it is not possible. However, I did the following code: ...
5
votes
0answers
485 views

8-bit AVR delay using TIMER0 (8-bit)

Using an Atmega328P clocked externally @ 16 MHz, this procedure is analogous to delay routines that use instructions to consume clock cycles. The intent of this algorithm is not to advocate any ...
7
votes
2answers
215 views

A simple clock in FORTH

I try to program a stopwatch/countdown clock in FORTH with Gforth (and using Gforth-specific words). I'm a complete beginner and the following code is the basic stuff (going to add an alarm function ...
10
votes
1answer
22k views

Angular 2 clock with RxJS Observable

I'm fairly new to Angular 2 and I started off with creating a clock for my app. I tried to stick to the official documentation tutorial. Folder structure: The CSS file is still empty and the HTML is ...
1
vote
2answers
3k views

Delaying a function call for 30 seconds using sleep() or checking the time in a loop

I need a way to delay a function call by 30 seconds on a machine that runs on electric power, not battery (if it matters). I have heard from my colleague not to use ...
3
votes
4answers
211 views

JavaScript clock

I am trying to build a clock. You can see the working code here. However, I feel like I can do much better in the JavaScript code. ...