Using the timer function .z.ts in q/kdb+

Note: You can now subscribe to my blog updates here to receive latest updates.

q/kdb+ has several pre-defined functions in the dot z namespace such as .z.a to get the IP address, .z.h to get the host, and .z.b to get the dependencies. Today, we will discuss a callback function in the dot z namespace called .z.ts.

.z.ts is a very simple timer function that is invoked at regular pre-configured intervals. The interval is set by \t command and is set to 0 by default.

For example:

q)\t
0i

To invoke a function regularly, you need to set the timer and define the .z.ts function. For example, if I want to print the current timestamp every 5 seconds, here is how I would do that:

First, set the timer using milliseconds:

q)\t 5000
Capitalizing On The Well being cialis online consultation Related Benefits of Female Orgasm Enhancement Girls are in a position to see what other adjustments you’ll need to make in terms of way of life as well as his intimate relationship. Generally, the causes are related to cialis 60mg a stress-full life, health ailments (hypertension, diabetes, and cardiac problems), lifestyle change and aging effects. Acai berry supplements viagra online overnight are quickly becoming one of the most popular herbal medicines, American ginseng is widely used as a tonic for the circulatory system and muscle building. However, both male and female with diabetes disorder pointed out difficulty in orgasm to a higher ratio. sildenafil 100mg viagra click to read more

Then, define .z.ts to print out the timestamp. To do that, we will use another handy pre-defined function in the dot z namespace, .z.P, that returns the current timestamp.

q).z.P
2020.06.16D18:12:36.976243000

As soon as you define .z.ts, you will start seeing timestamps being printed every 5 seconds:

q).z.ts:{0N!.z.P}
q)2020.06.16D18:13:47.490599000
2020.06.16D18:13:52.491541000
2020.06.16D18:13:57.490293000
2020.06.16D18:14:02.493378000
2020.06.16D18:14:07.491536000
2020.06.16D18:14:12.492940000

And that’s all there is to .z.ts. It’s a very simple function but can be very handy and you will encounter it quite frequently. For example, it is used in the sample publisher.q code provided by Kx:

// create timer function to randomly publish
// between 1 and 10 meter records, and between 1 and 5 grid records
.z.ts:{publishmeter[1+rand 10]; publishgrid[1+rand 5]}

Leave a comment

Your email address will not be published. Required fields are marked *