Is it possible to write a code in C that'll determine the execution speed of a particular piece of code?
Is it possible to write a code in C that'll determine the execution speed of a particular piece of code?
What do you want?
The kernel gives the programs the more execution time the higher their priority is. You can chose between the height of the priority on your program, but you usually can´t determine it on extern programs without programming the kernel, I think.
klausi
When I close my eyes nobody can see me...
I meant , can we know what time it takes for a keyword/statement in C to get executed(including its compilation,linking & everything..)
I only know a manual method in which u compile the code to assembly and count the time each instruction takes.
Pl. give me some good suggestions to do this...
Thanx,
gagig
how do u change the piority of a program may i ask ?
thnx
While designing the OS Priority can be assigned /changed by the scheduler.
I think i saw this somewhere in this book:
Sams Teach Yourself C++ for Linux in 21 days
I mean the catual source code, but i don't think it dealt with priority or other factors, try Sams web site and search in there.
Ünicode¬>world = 10.0£
Thanx I shall refer that book.
I have absloutly no idea about Unix and Linux but thread priorities are only available in windows nt (i'm not sure wot version it starts at) 2000 and XP. They are specified when launching a program and creating a thread. I'm not sure if you can alter a threads prioritiy during execution but it seems logical that you should. . . .
You cannot get an actual value unless you look at the cycle timing via instructions. However, you can get close enough for your purposes by using a program called a "profiler".
Better compilers come with 'profilers'. They run at the same time your code does and when you quit, they can tell you how much time your program spent in whatever places you want them to watch.
Enjoy.
wow sayeh!
this is great!
how do I use it in my code? Does profiler come along with VC++
compiler?
or examples of compilers that it comes along with??
this would be of great help!!
thanx a lot,
gagig
I found in VC++ there is a option called enable profile under project menu settings. I enabled it, but I'dn't see any info regarding time taken after compiling & linking.
Is what i did right? How can view the time info?
thanx,
gagig
in UNIX you can enter "nice" at the command prompt. however, the priority will not go in your favor, lol.Originally posted by Nutshell
how do u change the piority of a program may i ask ?
thnx
[edited]
actually it lowers the priority of the overall user process; thus in in regards to a multi-user setup. funny though huh?
[/edited]
Last edited by skyline; 02-05-2002 at 11:38 PM.