How do I use the timer?

If you defined a function called .z.ts, and enable q’s timer with \t n then q will call .z.ts every n milliseconds:

q).z.ts: {[] show .z.T}
q)\t 500
q)07:41:15.147
07:41:15.647
07:41:16.147
07:41:16.647
07:41:17.147
\t 0
q)

As shown above, \t 0 stops the timer.

To set the timer interval, you must give \t a literal integer. What that means is that, if you want to change the timer frequency at runtime (e.g., when building a simple scheduler), the following will not work:

q)i: 500
q).z.ts: {[] show .z.T; system “t i”; i *: 2}
q)\t 500
q)07:46:47.106
07:46:47.606
07:46:48.106
07:46:48.606
\t 0
q)

Notice what happens when we enter \t i at the repl:

q)\t i
0
q)

What we’ve done is use \t tomeasure the execution time of the expression i. To get the effect we want is, fortunately, easy once you see what is going on:

q)i: 500
q).z.ts: {[] show .z.T; system “t “, string i; i *: 2}
q)\t 500
q)07:59:59.694
08:00:00.195
08:00:01.195
08:00:03.196
\t 0
q)

By passing “t “, string i instead of “t i” to system, the q interpreter sees a literal integer.

One last detail: if you decide you need to delete the definition of .z.ts, you’ll need to use \x.