Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Compare execution time in C language

  1. Feb 20, 2010 #1
    1. The problem statement, all variables and given/known data
    I want to compare the execution times for DDA and Bresenham's Line algorithm using a C program. I used the clock_t command; I'm getting the execution time for Bresenham’s algorithm as 0.164835 but 0 for DDA.

    3. The attempt at a solution

    clock_t start,end;
    Bresenham's line algorithm code

    DDA line algorithm code

    Also I'm getting t=0.164835 for both codes separately. Whereas DDA line algorithm should take more time. What is it that I’m doing wrong?
  2. jcsd
  3. Feb 20, 2010 #2


    Staff: Mentor

    Your times aren't granular enough for what you're trying to measure. The basic unit of the clock_t type is seconds, which is way too large for measuring operations that are happening at clock rates in the gigahertz range.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook