Duration of Computations

I wondered how I can keep track of the duration of the computations conducted by Gauss. It looks like that there is more than one way of doing this. What is the most efficient and cleanest way of doing it? Can you please give an example? If I have procs in my code, where this duration procedure should be placed in my code? Thanks!

1 Answer



1



Generally, the usage of hidden global variables is discouraged. However, in this case, it might make sense. You could create a file with these contents:

// Create a global variable to use as a timer
// Make it long and ugly, since we will not have
// to reference it directly and this will make it
// less likely that another procedure would reference it
declare __my_code_start_seconds = 0;

// Procedure to set the global variable and start the timer
proc (0) = startCodeTimer();
    // set the global time variable to the number
    // of seconds since January 1, 1970 
    __my_code_start_seconds = timeutc();
endp;

proc (1) = printElapsedTime();
    local elapsed_sec;

    // Compute the number of seconds elapsed
    // since 'startCodeTimer' was called
    elapsed_sec = timeutc() - __my_code_start_seconds;

    // Multiply by 100, because 'etstr'
    // assumes that the input is in hundredths of a second
    retp(etstr(elapsed_sec * 100));
endp; 

then you can add the file with this code to your user library so it will always be available to you. Then you can just use the procedures to time your code, like this:

startCodeTimer();

// Wait 5 seconds
call sleep(5);

printElapsedTime();

and you should get output that looks like this:

5.00 seconds

aptech

1,218

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

REQUEST A FREE QUOTE

Thank you for your interest in the GAUSS family of products.

© Aptech Systems, Inc. All rights reserved.

Privacy Policy | Sitemap