timing

Precision timing of GDK3/GTK3 window update

北慕城南 提交于 2019-12-11 03:21:50
问题 I have an application written in C using GTK (although the language is probably unimportant for this question). This application has a fullscreen gtk_window with a single gtk_drawing_area . For the drawing area, I have registered a tick callback via gtk_widget_add_tick_callback which just calls gtk_widget_queue_draw every tick. Inside the drawing area draw callback, I change the color of the entire window at regular intervals (e.g., from black to white at 1Hz). Say that in this call to the

How can I make my python code run faster

喜夏-厌秋 提交于 2019-12-11 02:06:57
问题 I am working on code that loops over multiple netcdf files (large ~28G). The netcdf files have multiple 4D variables[time, east-west, south-north, height] throughout a domain. The goal is to loop over these files and to loop over each location of all of these variables in the domain and pull certain variables to store into a large array. When there is missing or incomplete files I fill the values with 99.99. Right now I am just testing by looping over 2 daily netcdf files but for some reason

How to determine the current Windows timer resolution? [duplicate]

白昼怎懂夜的黑 提交于 2019-12-11 01:29:27
问题 This question already has answers here : How to get the current Windows system-wide timer resolution [closed] (4 answers) Closed 5 years ago . It might be obvious, but I can't find/google the correct method to get the current system value of the timer resolution, which a program can set by timeBeginPeriod(n)/timeEndPeriod(n). I want to find out what's the current resolution... The Windows 7 default value seems to be 15.6 ms, but other applications or the machine vendor might have changed the

Python Animation Timing

一个人想着一个人 提交于 2019-12-10 18:14:46
问题 I'm currently working on sprite sheet tool in python that exports the organization into an xml document but I've run into some problems trying to animate a preview. I'm not quite sure how to time the frame rate with python. For example, assuming I have all of my appropriate frame data and drawing functions, how would I go about coding the timing to display it at 30 frames per second (or any other arbitrary rate). 回答1: The easiest way to do it is with Pygame: import pygame pygame.init() clock

C++ - Execute function every X milliseconds

99封情书 提交于 2019-12-10 12:06:19
问题 I can't seem to find a good answer to this: I'm making a game, and I want the logic loop to be separate from the graphics loop. In other words I want the game to go through a loop every X milliseconds regardless of how many frames/second it is displaying. Obviously they will both be sharing a lot of variables, so I can't have a thread/timer passing one variable back and forth... I'm basically just looking for a way to have a timer in the background that every X milliseconds sends out a flag

MATLAB scatter3, plot3 speed discrepencies

浪子不回头ぞ 提交于 2019-12-09 17:14:31
问题 This is about how MATLAB can take very different times to plot the same thing — and why. I generate 10000 points in 3D space: X = rand(10000, 1); Y = rand(10000, 1); Z = rand(10000, 1); I then used one of four different methods to plot this, to create a plot like so: I closed all figures and cleared the workspace between each run to try to ensure fairness. Bulk plotting using scatter3: >> tic; scatter3(X, Y, Z); drawnow; toc Elapsed time is 0.815450 seconds. Individual plotting using scatter3

scheduleAtFixedRate not starting the task at specified delay

空扰寡人 提交于 2019-12-08 10:44:55
问题 I am using SchedulerExecuterService to execute a task after specified delay and at given intervals. ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); scheduler.scheduleAtFixedRate(taskThread,60 ,120 ,TimeUnit.SECONDS); What happening is first time taskThread is not starting after delay of 60 sec, it is started after delay of more than 60 secs. Whereas the next executions started at correct intervals of 120 secs(not exactly 120 secs but there is a very minute delay

What's the best timing resolution can i get on Linux

醉酒当歌 提交于 2019-12-08 10:19:52
问题 I'm trying to measure the time difference between 2 signals on the parallel port, but first i got to know how much accurate and precise is my measuring system (AMD Athlon(tm) 64 X2 Dual Core Processor 5200+ × 2) on SUSE 12.1 x64. So after some reading i decide to use clock_gettime(), first i get the clock_getres() value using this code: /* * This program prints out the clock resolution. */ #include <stdio.h> #include <stdlib.h> #include <time.h> int main( void ) { struct timespec res; if (

Call function multiple times in the same moment but execute different calls with delay in nodejs

半世苍凉 提交于 2019-12-08 04:02:11
问题 I need to call a function multiple times from different contexts, but i need that each call fires not before that one second has passed after the previous call started. i'll make an example: var i = 0; while(i<50) { do_something(i) i++ } function do_something(a) { console.log(a) } I want that this log: '1', then after a second '2', then after a second '3', then after a second '4'... I can't use simple setInterval or setTimeout because this function 'do_something(param)' can be called in the

How to start a service at a specific time

无人久伴 提交于 2019-12-08 03:56:14
问题 Am creating an application that fetch data from webservice. I have been while(true) and sleeping the loop at a specific milliseconds.. i had like to make the service action(fetching data from webservice) to always start at a specific time.. instead on being on always and pausing by Thread.sleep(milli) ... Thanks this is what have been using while(true) { ///pullDataFromWebservice(); Thread.sleep(600000); } 回答1: Use the Alarm API. It is way safer than having a sleep & poll service. Why?