Questions tagged [gettimeofday]

The function gettimeofday() can get the time as well as a timezone.

Read more in the Linux Reference.

100 questions
0
votes
0 answers

Time measurement of single arithmetic operation with gettimeofday()

I am trying to measure the time of atomics operations like bitwise for example. The problem I had is that I can't just compute 0&1, because the IDE doing optimisation and ignoring this command, so I had to use assignment num = 0&1. So to get the…
limitless
  • 669
  • 7
  • 18
0
votes
4 answers

gettimeofday clock_gettime solution to generate unique number

My process runs multiple instances (processes) and multiple threads and all of them write to the same database. As soon as the request is placed, a unique req id is generated for the record to be added to the proprietary db. Here are our…
Kiran
  • 993
  • 2
  • 9
  • 14
0
votes
1 answer

vdso gettimeofday with 64 bit kernel & application compiled for 32 bit

is vdso supported for a 32 bit application which is running on a 64 bit kernel with glibc version 2.15.? If yes, how do I make it work for 32 bit application running on 64 bit kernel.? Cause even though dlopen on "linux-vdso.so.1" is success, dlsym…
user3465381
  • 41
  • 1
  • 4
0
votes
1 answer

How to get every integer second in a c program

I am wondering if there is a way to get every integer second in a c program. I tried to use 'gettimeofday' function to get the current time and then if the current fractional part of second falls into a region (say larger than 0.9 and smaller than…
Toga
  • 19
  • 2
0
votes
4 answers

Error with -mno-sse flag and gettimeofday() in C

A simple C program which uses gettimeofday() works fine when compiled without any flags ( gcc-4.5.1) but doesn't give output when compiled with the flag -mno-sse. #include #include int main() { struct timeval s,e; float…
0
votes
1 answer

Bandwidth readings increase while writing large file

We've been measuring the bandwidth of two external HDDs in class using gettimeofday. Surprisingly enough, and after several repeats (three measurements per execution, executed three times), we found that writing a 2500MB file was faster than writing…
agsergi
  • 165
  • 1
  • 9
0
votes
1 answer

eglibc: Getting Uptime in Milliseconds

I want to write a log-output with the same format as the kernel-log: [ 11.947248] fsl-gianfar ffe24000.ethernet eth0: Link is Up The timestamp should have the same time-reference as the kernel time. This means, when a log-message is emitted at…
Charly
  • 1,270
  • 19
  • 42
0
votes
2 answers

getting chrono time in specific way

I have following C code: uint64_t combine(uint32_t const sec, uint32_t const usec){ return (uint64_t) sec << 32 | usec; }; uint64_t now3(){ struct timeval tv; gettimeofday(&tv, NULL); return combine((uint32_t) tv.tv_sec,…
Nick
  • 9,962
  • 4
  • 42
  • 80
0
votes
1 answer

Why does gettimeofday return weird tv_sec?

I have an application that calls gettimeofday to store the tv_sec in which that part of the code starts to run. This code is very simple: struct timeval tvnow; gettimeofday(&tvnow); int initialTime = tvnow.tv_sec; It normally works fine but…
althor
  • 739
  • 2
  • 9
  • 21
0
votes
1 answer

questions related to source code of PHP uniqid()

In PHP source code function uniqid() have following C code: (I removed some types to shorten it) //... struct timeval tv; gettimeofday(&tv, NULL); int sec = (int) tv.tv_sec; int usec = (int) (tv.tv_usec % 0x100000); // The max value usec can have…
Nick
  • 9,962
  • 4
  • 42
  • 80
0
votes
1 answer

Why changing timezone from shell does not affect gettimeofday() even after reboot?

I have changed on Ubuntu timezone using dpkg-reconfigure tzdata from UTC+2 to UTC+0 but running C code gettimeofday() still showing tz_minuteswest and tv_sec in previous timezone even after reboot. Only after running C code below once gettimeofday()…
0
votes
1 answer

Hyperthreading effects on gettimeofday and other time measurements

while I was benchmarking a CPU with hyperthreading with BLAS matrix operations in C, I observed a nearly exact doubling of the runtime of the functions when using hyperthreading. What I expected was some kind of speed improvement because of out of…
bknux
  • 536
  • 1
  • 5
  • 18
0
votes
1 answer

Self-correcting periodic timer using gettimeofday()

I have a loop which runs every X usecs, which consists of doing some I/O then sleeping for the remainder of the X usecs. To (roughly) calculate the sleep time, all I'm doing is taking a timestamp before and after the I/O and subtract the difference…
Erik Nyquist
  • 1,267
  • 2
  • 12
  • 26
0
votes
1 answer

gettimeofday() returns negative value some times

I am getting negative values sometimes for below code. I don't understand this.Can any one explain why it would happen. int64_t gettimelocal() { struct timeval Time; if(-1 == gettimeofday(&Time,NULL)) { perror("gettimeofday"); …
linuxman
  • 83
  • 3
  • 10
0
votes
1 answer

Timer in C Linux

I was trying to create a timer using gettimeofday. A function "time" has been called for resetting and getting the current time for the timer. But the program is giving garbage values when i tried to get second tine value. Please…