timer

Measure CPU time on Windows using GetProcessTimes

人走茶凉 提交于 2020-01-14 02:09:26
问题 I would like to measure CPU time of some function. I know how to use GetProcessTimes , but I have a problem implementing it with some kind of 'restarting': Normally, I would do it like this: #include "stdafx.h" #include <math.h> #include <windows.h> double cputimer() { FILETIME createTime; FILETIME exitTime; FILETIME kernelTime; FILETIME userTime; if ( GetProcessTimes( GetCurrentProcess( ), &createTime, &exitTime, &kernelTime, &userTime ) != -1 ) { SYSTEMTIME userSystemTime; if (

TimerTask can't update the JavaFX Label text

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 01:34:09
问题 I have a fairly simple JavaFX GUI application which has an label that shows how much time is left until a certain action starts. To achieve this, I've created a DownloadTimer class as shown below: public class DownloadTimer(){ private int minutes; private int seconds; private Timer innerTimer = new Timer(); private TimerTask innerTask; private boolean isActive; public DownloadTimer(int minutes, int seconds) { if (seconds > 60) { int minToAdd = seconds / 60; this.minutes = minutes; this

Countdown timer increase on interaction?

痞子三分冷 提交于 2020-01-13 19:38:40
问题 I have a form that I want to close after 5 seconds if no mouse interaction is done but if any mouse interaction is done I want it to close countdown + 5 seconds and each interaction would increase it by 5 seconds. This is what I came up with so far: int countdown = 5; System.Timers.Timer timer; Start timer timer = new System.Timers.Timer(1000); timer.AutoReset = true; timer.Elapsed += new System.Timers.ElapsedEventHandler(ProcessTimerEvent); timer.Start(); The event private void

Running an Async Task Inside a timer in Android

戏子无情 提交于 2020-01-13 15:03:15
问题 I am working on a basic chat-type application and at present I am running the code, given below : class GetMsgs extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(MsgViewActivity.this); pDialog.setMessage("Fetching.."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } @Override protected String doInBackground(String... arg0) { Intent intent = getIntent(); String tmp = intent

How can I make this timer run forever?

十年热恋 提交于 2020-01-13 11:12:13
问题 from threading import Timer def hello(): print "hello, world" t = Timer(30.0, hello) t.start() This code only fires the timer once. How can I make the timer run forever? Thanks, updated this is right : import time,sys def hello(): while True: print "Hello, Word!" sys.stdout.flush() time.sleep(2.0) hello() and this: from threading import Timer def hello(): print "hello, world" sys.stdout.flush() t = Timer(2.0, hello) t.start() t = Timer(2.0, hello) t.start() 回答1: A threading.Timer executes a

Basic wxWidgets Timer

守給你的承諾、 提交于 2020-01-13 05:52:08
问题 Being new to wxWidgets I need some example code of how to get the wxTimer working. The reference gives 3 ways to use it but doesn't include sample code for any of them. Optimally, I'd like to get method 2 working. 回答1: (from the samples/widgets/gauge.cpp:) Set up your event constants enum { GaugePage_Reset = wxID_HIGHEST, GaugePage_Progress, Wire the event to your member function (using your event constant) EVT_TIMER(GaugePage_Timer, GaugeWidgetsPage::OnProgressTimer) and then you'll need to

timer accuracy: c clock( ) vs. WinAPI's QPC or timeGetTime( )

爷,独闯天下 提交于 2020-01-12 23:48:23
问题 I'd like to characterize the accuracy of a software timer. I'm not concerned so much about HOW accurate it is, but do need to know WHAT the accuracy is. I've investigated c function clock(), and WinAPI's function QPC and timeGetTime, and I know that they're all hardware dependent. I'm measuring a process that could take around 5-10 seconds, and my requirements are simple: I only need 0.1 second precision (resolution). But I do need to know what the accuracy is, worst-case. while more accuracy

Common Lisp Timer

有些话、适合烂在心里 提交于 2020-01-12 15:55:49
问题 I would like to start a timer in my common lisp application that after a certain amount of time it will call a certain method. What would be the best way to accomplish this? 回答1: Would something as simple as SLEEP work? 回答2: It's SBCL-dependent, but you might want to try out Zach Beane's TIMER. 回答3: http://www.cliki.net/TIMER implements relative time based scheduling, which i THINK is what you mean 来源: https://stackoverflow.com/questions/1986822/common-lisp-timer

Real time linux : disable local timer interrupts

故事扮演 提交于 2020-01-12 08:13:13
问题 TL;DR : Using linux kernel real time with NO_HZ_FULL I need to isolate a process in order to have deterministic results but /proc/interrupts tell me there is still local timer interrupts (among other). How to disable it? Long version : I want to make sure my program is not being interrupt so I try to use a real time linux kernel. I'm using the real time version of arch linux (linux-rt on AUR) and I modified the configuration of the kernel to selection the following options : CONFIG_NO_HZ_FULL

Real time linux : disable local timer interrupts

给你一囗甜甜゛ 提交于 2020-01-12 08:13:09
问题 TL;DR : Using linux kernel real time with NO_HZ_FULL I need to isolate a process in order to have deterministic results but /proc/interrupts tell me there is still local timer interrupts (among other). How to disable it? Long version : I want to make sure my program is not being interrupt so I try to use a real time linux kernel. I'm using the real time version of arch linux (linux-rt on AUR) and I modified the configuration of the kernel to selection the following options : CONFIG_NO_HZ_FULL