Project

Profile

Help

xquery timing

Added by Anonymous over 16 years ago

Legacy ID: #4657895 Legacy Poster: James Fuller (cutlass)

Wondering if anyone has any suggestions on how to achieve a roughly accurate timing mechanism within XQuery ? Looking to time individual processes within XQuery .... something like this? let $start-time :=current-dateTime() ... some process let $end-time :=current-dateTime() let $timing := $end-time - $start-time thoughts? cheers, Jim Fuller


Replies (3)

Please register to reply

RE: xquery timing - Added by Anonymous over 16 years ago

Legacy ID: #4657936 Legacy Poster: Michael Kay (mhkay)

It's explicitly defined that current-dateTime() returns the same value throughout the execution of the query. A better bet is to call Java System.currentTimeMillis() as an extension function. But you need to be careful there too, because of lazy evaluation - a variable won't be evaluated until its value is needed, so the execution time will appear shorter than it is (probably negative, in fact, since you access endTime before startTime. You can get around that by outputting the actual time values as comments into the result tree - but of course that will increase the execution cost. I very rarely do this myself. I either measure total query time externally to the query (use -repeat:N and -t on the command line) or if I need something finer-grained to see where the time is actually going, I use Java profiling.

RE: xquery timing - Added by Anonymous over 16 years ago

Legacy ID: #4658248 Legacy Poster: James Fuller (cutlass)

aha, I messed up on current-dateTime() was wondering what the issue was there ... thx for clearing up the behavior here. I was using java system command to do this ... I just need a rough method for timing inside of queries, basically so I know my baseline and if I am getting slower or faster ;) cheers once again, Jim Fuller

RE: xquery timing - Added by Anonymous over 16 years ago

Legacy ID: #4658267 Legacy Poster: Michael Kay (mhkay)

I would recommend using the command line. Run with "-t -repeat:10" or "-repeat:100" - enough repetitions of the query to run for at least 30 seconds if you want the results to be moderately consistent.

    (1-3/3)

    Please register to reply