4 Replies Latest reply: Jan 12, 2009 8:39 AM by notnick RSS

    Timing C Code execution

      I am attempting to increase time the c code execution time as I improve the performance of my algorithm. I tried using time.h and when doing something simple like
      The compiler responds with
      called object ‘&time’ is not a function

      What is the best method for timing the c execution time given we are not using the Alchemy gcc?
        • 1. Re: Timing C Code execution
          In FlexUnit uses a method - getTimer
          var _start:Number = getTimer();
          var _stop:Number = getTimer();
          var _result:String = (_stop-_start).toString();
          We receive time in milliseconds
          Accuracy is not defined... It depends on many parametres of system.
          • 2. Re: Timing C Code execution
            normanDig Community Member
            Yea...I am looking for something on the C side of things. I tried using clock() also but I don't feel like the values are correct. The timings stay the same every time I run the program even with changes to the C code and some other odd results. Any thoughts? I could just be doing something wrong...does anyone know if this should work???
            • 3. Re: Timing C Code execution
              normanDig Community Member
              Ok so ignore all my previous comments (Programmer Error). Bad programming on my part. I am porting Java code to C code that I was previously using as the back end of my flash application. In that code I had a matrix named time and therefore it was overwriting the time function keyword. Thanks for the thoughts notnick.
              • 4. Re: Timing C Code execution
                notnick Community Member
                On C as probably using structure timer_t it is possible to receive some
                Time pieces. But in milliseconds - you do not receive exact results...
                I tried it in alchemy works but it is very strange. Also has stopped on an example above.