Programming :: Difference In Time Recorded By Clock_gettime() And TSC?
Jan 24, 2011
I want to measure the time it takes to execute a C function. The question is which is the best method to record time. After a lot of searching online, I found two ways [URL]:
a. using clock_gettime(CLOCK_MONOTONIC, &t)
b. using TSC
I call the C function 50 times (recording the time it takes for each call). The average is found only for the last 35 calls.
Using (a), I get:
48345 us
28350 us
28379 us
27716 us
[code]....
Average time for the last 35 loops: 121450.47 microseconds
Average for the last 35 loops: 27236.66 cycles What could be causing the strange value of 3322259 us in method (a)? I could just use method (b) but I would like to know what is going on here... Btw, I am using a desktop - with Linux debian 2.6.26 #1 SMP.
My computer has different time when booting to linux or Windows.How to make the time the same?My computer time is 10:57pm Apr 14 when booting to linux.My computer time is 2:57am Apr 14 when booting to Windows Vista Home Premimum SP2.Both OS are set to the same time zone (GMT-5. Eastern Time US & Canada).
I am slowly getting accustomed with linux issues and its different programming compilation stuffs. and i must say am truly liking it. Now i am facing this typical error , "undefined reference to `clock_gettime'" while i am compiling a code, which is not mine as it required to install a simulator. Now i have read about this type for the last 2 days and i have included "-lrt" in the make file and included <time.h> in the header files which was missing but still i am getting that error.
Now matter how many times i run the make file with the required changes its still giving me this error, which i have comprehended as mainly linking problem rather than a compilation issue.
My Linux system was last rebooted few hours ago. But it seems little confusing for me to figure out the exact reason behind it. I guess following command should justify what i meant to say.
Code: # date Wed May 11 13:22:49 IST 2011 # last | grep "May 10" reboot system boot 2.6.18-194.el5 Tue May 10 17:35 (19:46) root pts/1 XXXX Tue May 10 17:24 - 18:18 (00:53)
[Code]...
My question is Why the uptime is saying that the system is up since last 47 min.It should be more than 1 day if i m not wrong.
I am calling clock_gettime() function to get time with nano seconds accuracy. My program works fine on Ubuntu but have high CPU usage problem on CentOS 5. it takes 40% CPU on Ubuntu and 90% CPU on CentOS. Kindly give me solution so that I can reduce high CPU usage problem on CentOS. You can build this code like: "gcc -lrt gettime.c -o gettime.e"
When i install libdrm, i get the following error:checking for clock_gettime... no.checking for clock_gettime in -lrt... no.configure: error: Couldn't find clock_gettime
It seems that it cannt find clock_gettime function, but i find it as follow: $ grep clock_gettime /usr/include/time.h extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
I am interested in learning 3D programming. The thing is, I would hate to put too much effort to learn something that doesn't have future and is dying. My favorite language at the time is Java. My goal is professional programming.
So I have several questions: 1. Should I learn JOGL or start learning C++ and do C++ openGL programming? 2. Is there a big difference between JOGL and C++ openGL programming? 3. Is it worth to learn openGL? Does it have a future? 4. Is it a big difference between openGL and directX coding? 5. If choosing Java, then JOGL or LWJGL?
I am using Debian linux. I have 100 timers running. If a timer expired which will generate a signal and it was mapped to a same function handler. All the timers are mapped to one function handler. The problem is if the timer expires one at a time, the function handler called at a time. But if the 2 timers expires at a time, the function handler is called one time only instead 2 times. Is it possible to invoke the function handler as many times based on timer expirary happens simultaneoulsy?
I am trying to set time using settimeofday in linux. But it sets local time. i.e works like SetLocalTime in windows. But I want to set system time(like SetSystemTime in windows). I could'nt find no other api in linux. What should i do? I had tried with mktime/gmtime apis
Ubuntu 10.04 lucid. sun-java6-jdk has been dropped from the Multiverse section of the Ubuntu archive. They recommend using openjdk-6 instead. Is there any difference between these 2 packages?
I know it's a very silly question but could someone please explain the difference between "/bin/bash" & "/bin/sh" I was under the impression that both are same but following output on my Ubuntu 8.10 is making me raise my eyebrows.
I am not clear with difference between hexdump and objdump and coredump. I wrote a small program
Code: main (){ int a=2; int b=4; int k=b/a; int m=9;
[Code].....
Some of the above instructions such as 89 d0 should be present in hexdump. What exactly is the hexdump ,objdump and coredump and what is their importance?
I have been spending time (starting yesterday) reverse-engineering GTK+ to get my programming skills up. I came across a struct in the headers (_GtkArg, which was then typedeffed into GtkArg) that includes a union in it that has pretty much the same properties as a struct. Then, there was a struct inside the union.
I'm confused. Just what is the difference between a union and a struct?
P.S. I am using GTK's native C programming language.
What is the difference between *ptr++ and (*ptr)++. In my opinion the terminology is all over the place so if you could give an example it would be better.
I was going through some exercise given in my school. I have read the C book but I am not able to understand some part. That is static variable. What exactly is a static variable and what does it do? I saw in Linux Kernel Programming external and exported are also some thing. I am not getting the difference between static,EXPORT_SYMBOL,external variable types. If I make a kernel module then how will I make sure that my variable is visible to the kernel. Is this what it is all talking about? I have checked this page [URL].
I am starting to learn Linux graphical programming. Most of codes in my hands were written based on xlib, which is a kind of old graphic lib. I see some developers more interested in openGL. Then what's the difference between xlib and openGL? And which one is more popular used in which industry area?
I recently switched to Ubuntu and I'm loving it, except i am having sound problems with both my laptop and my desktop.My laptop is using an internal microphone (it is a Toshiba Satellite P500) but the mic is not recognized, I hook up my M-Audio USB audio interface which has my studio mic connected to it, it gets recognized as an input device but it doesnt recordSame thing on my desktop, it gets recognized, doesnt record.My laptop is 64-bit and my desktop is 32-bit, both have Ubuntu 10.04
Using Debian Lenny I recorded a wav file with Audacity to burn to a cd with K3b.The problem is when I played the cd with KsCD; it wouldn't stop when it got to the end; it just kept studdering. I didn't have problems using KsCD to play CDs I had ripped and then burned with K3b.Is this a problem with KsCD, or do I need to do something when I finish the file with Audacity?
I recorded some clips on the internet through the sound card withAudacity. I exported the recording as a wave file, and burnt it to a CD. The problem is stop playing. It comes to the end and just repeats the last fraction of a second over and over.I used K3b to burn other audio CDs that I copied and didn't havea problem with KsCD playing them. Is this a problem with Audacity,KsCD or did I do something wrong?I recorded the file; saved project and then exported as a wave file
Now, I'm ready to run my program, and my code is based on 32bit version. So I run the program on Ubuntu 9.10 32bit. And I got running time for 48s. But that's a bit slower than I expected; the program has bunch of File I/O processing but the result(48s) just doesn't make sense compared to given initial data set. So I just run the same program and same initial data set on Ubuntu 9.10 64bit ver. Then, bang!! it took 1.4s to finish the job.
Do you have any thoughts what kind of fact might make this significant difference? The differences b/w those two OS are "32 vs 64" and 32bit version has Java SDK, Eclipse, Apache2, Mysql, PHP, CGI, and python. We-server service is running but because I'm not really running web server. Did the result come from these background programs?
-- I tested it on the both OS in the same situation as possible as I can. (reboot->test)
-- BTW 64bit one doesn't have those programs. I just installed on my external hard drive, so it's literary PURE one. (32bit one also in the same HDD)
In our college all the systems (running on windows xp) have TURBO C/C++ installed on them which we use for C programming. I recently installed ubuntu 10.04 on me laptop (DELL Inspiron 14R (N4010) with some modifications) i read somewhere on the internet that Gedit can be used for writing a programme in ubuntu which can be compiled using gcc. Well if i use Gedit rather than Turbo c will i experience any differnce?, i mean is there any problem in doing so?? Or i should prefer running turbo c using DOS BOX?