How can I measure the performance of my q code?
Sunday, March 27, 2011 at 12:00PM
kdbfaq in Performance, \t, \ts, code profiling, do, kdb training video, podcast, time, video podcast

The simplest way to time something in q is to use the \t command:

q)f: {[] do[100000; 2 + 2]}
q)\t f[]
10
q)

\t executes its argument and returns the number of milliseconds that elapsed - i.e., wall clock time (except when you are using \t in its other sense, i.e., setting or getting the time between timer events).

When using kdb as a database server, you will want to use one or more of Simon's logging scripts as a starting point. These tremendously useful scripts enable you to record every incoming query as well as measure the time taken by every incoming query. That way you can calculate summary statistics on actual database performance in order to find and fix intermittent problems.

Article originally appeared on online book - kdb+/q faq - Kdb+ is the registered trademark of Kx Systems, Inc. (http://www.kdbfaq.com/).
See website for complete article licensing information.