time

Trouble with threads in a function to exec another function after X time

别来无恙 提交于 2020-01-24 01:13:11
问题 I am trying to create this function in order to exec another function after X time: void execAfter(double time, void *(*func)(void *), t_params *params); I have made an Thread encapsulation and a Time encapsulation (objects Thread and Time). What I want to do in pseudo code: Call execAfter instantiate Thread call thread->create(*funcToExec, *params, timeToWait) [inside thread, leaving execAfter] instanciate Time object wait for X time exec funcToExec delete Time object [leaving thread, back

Time measuring in PyOpenCL

ぐ巨炮叔叔 提交于 2020-01-23 16:46:26
问题 I am running a kernel using PyOpenCL in a FPGA and in a GPU. In order to measure the time it takes to execute I use: t1 = time() event = mykernel(queue, (c_width, c_height), (block_size, block_size), d_c_buf, d_a_buf, d_b_buf, a_width, b_width) event.wait() t2 = time() compute_time = t2-t1 compute_time_e = (event.profile.end-event.profile.start)*1e-9 This provides me the execution time from the point of view of the host (compute_time) and from the device (compute_time_e). The problem is that

time.time_ns() is not returing nanoseconds correctly on macOS?

最后都变了- 提交于 2020-01-23 16:14:52
问题 Starting from Python 3.7 we have new time functions supporting nanosecond resolution. However, I am not sure how time.time_ns() is supposed to work. Look at the following example: >>> for n in range(10): ... time.sleep(random.random()) ... print((time.time(), time.time_ns(), time.monotonic_ns())) ... (1545306865.8667252, 1545306865866727000, 439497985080) (1545306866.084973, 1545306866084974000, 439716229679) (1545306866.2972622, 1545306866297264000, 439928562751) (1545306866.635714,

time.time_ns() is not returing nanoseconds correctly on macOS?

穿精又带淫゛_ 提交于 2020-01-23 16:14:22
问题 Starting from Python 3.7 we have new time functions supporting nanosecond resolution. However, I am not sure how time.time_ns() is supposed to work. Look at the following example: >>> for n in range(10): ... time.sleep(random.random()) ... print((time.time(), time.time_ns(), time.monotonic_ns())) ... (1545306865.8667252, 1545306865866727000, 439497985080) (1545306866.084973, 1545306866084974000, 439716229679) (1545306866.2972622, 1545306866297264000, 439928562751) (1545306866.635714,

Convert TLE times (decimal days) to seconds after epoch

偶尔善良 提交于 2020-01-23 11:08:07
问题 The standard two line element (TLE) format contains times as 2-digit year plus decimal days, so 16012.375 would be January 12, 2016 at 09:00. Using python's time or datatime modules, how can I convert this to seconds after epoch? I think I should use structured time but I am not sure how. seconds_of is a fictitious function - need to replace with something real. EDIT: It will be most helpful if the answer is long (verbose) - like one step per line or so, so I can understand what is happening.

Today's time in time tag

本小妞迷上赌 提交于 2020-01-23 08:16:06
问题 For date ranges, I currently use this format (until precise specifications come up): <time datetime="2012-11">November 2012</time> - <time datetime="2013-01">January 2013</time> I was wondering if there is, or will be, a way to indicate today's date. I mean, I know we can do this: <time datetime="2013-03-05">Today</time> but I would like to have something like this: <time datetime="now">Today</time> If not, I plan to leave the "Today" word with no extra markup. Would you recommend a better

is anybody doing anything about 2038 time_t bug? [duplicate]

我的梦境 提交于 2020-01-23 07:49:11
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: What should we do to prepare for 2038? I don't mean 'people' in the abstract. I mean are you doing anything and if so what? I am an ancient programmer and recall when I wrote COBOL in the late 70's saying to others in my team "you know - this isn't going to work in 2000". To which the reply was "yeah but this system wont be in use by then, that's 25 years away". 2038 is 28 years away. 回答1: I add a disclaimer to

How to combine date and time from different MySQL columns to compare to a full DateTime?

核能气质少年 提交于 2020-01-23 05:14:30
问题 Column d is DATE, column t is time, column v is, for example, INT. Let's say I need all the values recorded after 15:00 of 01 Feb 2012 and on. If I write SELECT * FROM `mytable` WHERE `d` > '2012-02-01' AND `t` > '15:00' all the records made before 15:00 at any date are going to be excluded from the result set (as well as all made at 2012-02-01) while I want to see them. It seems it would be easy if there were a single DATETIME column, but there are separate columns for date and time instead

Will getting the current date/time be thread-safe in C++20?

混江龙づ霸主 提交于 2020-01-23 04:43:33
问题 Short Question Up to and including C++17, C++ provides no thread-safe way to get the current time or date. Will this be fixed in C++20? Long Question The only portable way to get the current time and date is by using the std::gmtime or std::localtime functions. Remnants from the early days of C, these functions convert a given time since an implementation-defined epoch into calender time (for example, 1515153600 into Fri, 05 Jan 2018 12:00:00 GMT). The only downside, however, is that those

Trouble measuring the elapsed time of a CUDA program and CUDA kernels

南笙酒味 提交于 2020-01-23 04:11:15
问题 I currently have three methos of measuring the elapsed time, two using CUDA events and the other recording start and end UNIX. The ones using CUDA events measure two things, one measures the entire outer loop time, and the other sum all kernel execution times. Here's the code: int64 x1, x2; cudaEvent_t start; cudaEvent_t end; cudaEvent_t s1, s2; float timeValue; #define timer_s cudaEventRecord(start, 0); #define timer_e cudaEventRecord(end, 0); cudaEventSynchronize(end); cudaEventElapsedTime(