#43 stopwatch

closed-fixed
5
2008-03-07
2008-03-07
futurdorko
No

Something has recently changed because the following script crashes gretl now, whereas about a couple of weeks ago worked perfectly.

<i>
nulldata 1000

set stopwatch

# COMMANDS

time = $stopwatch

# COMMANDS

printf "Execution Time: %g seconds\n", $stopwatch - time
</i>

The problem is the subtraction [- time]. Without that it still runs fine.

Discussion

  • Logged In: YES
    user_id=1368575
    Originator: NO

    I have no time to debug this right now, but the problem is related to the fact that "time" is a special string (as in, eg "genr time"). In fact, IMO you shouldn't be able to assign anything to "time" anyway. For the moment, just use another identifier and you'll be ok.

     
  • futurdorko
    futurdorko
    2008-03-07

    Logged In: YES
    user_id=1533827
    Originator: YES

    Oh i see..
    may i suggest to highlight in a different way all the reserved word in the editor? Maybe in italics..

     
  • Allin Cottrell
    Allin Cottrell
    2008-03-07

    Logged In: YES
    user_id=330339
    Originator: NO

    The use of "time" as a built-in dummy variable, as in
    "genr time", is intended as simply a convenience. I've now
    changed things so that you can define "time" as you wish.

    However, you are misusing $stopwatch (the documentation on
    this should be fixed): each time you access the variable
    the clock is reset; there's no need to subtract a previous
    value.

     
  • Allin Cottrell
    Allin Cottrell
    2008-03-07

    • assigned_to: nobody --> allin
    • status: open --> closed-fixed