cancel
Showing results for 
Search instead for 
Did you mean: 

sub micro second

analyst_tech_jo
New Contributor
1. Why is \t not showing nano second level detail ? Anyway this can work ?


2. I did the following :
0N!.z.N; h:hopen `:localhost:5001; 0N!.z.N

Result:
0D00:01:25.581071000
0D00:01:25.582701000

Difference:
001630000j nanoseconds

Question:
How can this be decreased within q itself ? Anything sub micro seconds ?

2 REPLIES 2

effbiae
New Contributor
>nanoseconds

just getting the current time can take up to 2 microseconds:

q)1_"j"$deltas (.z.n;.z.n;.z.n;.z.n;.z.n;.z.n;.z.n;.z.n)
0 -1000 0 0 -1000 0 -2000

so even if the OS gave kdb+ the last three digits, they would just be noise due to the variation above.

so it wo

charlie
New Contributor II
New Contributor II
​variations of \t include
\t:n expr
\ts expr
\ts:n expr

where n is a positive integer indicating how many times to execute expr. Equivalent to

\ts do[n;expr]

useful for expr which do not have side-effects (and even then for some); can divide the resulting timing by n to get avg time.

The timing source for \t varies across platforms, and considering the jitter due to process scheduling/interrupts, it's probably not meaningful to try to time a single run to nS precision.