Determine speed of code

This is a discussion on Determine speed of code within the C Programming forums, part of the General Programming Boards category; Is it possible to write a code in C that'll determine the execution speed of a particular piece of code?...

  1. #1
    Unregistered
    Guest

    Determine speed of code

    Is it possible to write a code in C that'll determine the execution speed of a particular piece of code?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    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...

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    10

    Re: Determine speed of code

    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

  4. #4
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    how do u change the piority of a program may i ask ?

    thnx

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    10
    While designing the OS Priority can be assigned /changed by the scheduler.

  6. #6
    Registered User bljonk's Avatar
    Join Date
    Oct 2001
    Posts
    70

    Arrow saw this somewhere

    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£

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    10

    Smile Re: saw this somewhere

    Thanx I shall refer that book.

  8. #8
    Registered User
    Join Date
    Jan 2002
    Posts
    381
    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. . . .

  9. #9
    Sayeh
    Guest
    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.

  10. #10
    Registered User
    Join Date
    Jan 2002
    Posts
    10

    Question

    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

  11. #11
    Registered User
    Join Date
    Jan 2002
    Posts
    10

    Question

    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

  12. #12
    Registered User skyline's Avatar
    Join Date
    Dec 2001
    Posts
    49
    Originally posted by Nutshell
    how do u change the piority of a program may i ask ?

    thnx
    in UNIX you can enter "nice" at the command prompt. however, the priority will not go in your favor, lol.

    [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 10:38 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-21-2006, 06:52 AM
  2. Flight Simulator Wind Speed!!
    By Dilmerv in forum C++ Programming
    Replies: 6
    Last Post: 03-19-2006, 11:40 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  4. Seems like correct code, but results are not right...
    By OmniMirror in forum C Programming
    Replies: 4
    Last Post: 02-13-2003, 12:33 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21