On 06/14/2018 03:08 PM, Simon Slavin wrote:
On 14 Jun 2018, at 8:33am, x <tam118...@hotmail.com> wrote:
Could someone describe what the return values real, user and sys mean and why
there’s sometimes a big difference between real and the sum of user & sys?.
[The following is simplified for clarity.]
'real' -- Elapsed time between the start and end of the command, as measured by
the clock on your wall. Sometimes called 'wall time'.
The other two figures both concern just the process you're interested in,
ignoring the many other things the computer is doing at the same time like
seeing if you've clicked your mouse, updating your screen, checking to see if
your laptop battery is going to run out, etc..
'user' -- Processor time taken by the command itself. If you look at all the
source code for that command, this is the time taken to run that source code.
'sys' -- Processor time taken to execute the system calls the command used. If
the command used system calls to find the current time, allocate memory, and
write some bytes to a file, the amount of time each system call took
contributes to 'sys', not 'user'.
If 'sys' + 'user' > 'real', something weird happened.
Multi-threaded apps often have (sys+user)>real. And you can
build/configure SQLite to use multiple threads when sorting large
amounts of data, so it is possible. Not terribly common though, I would
think.
If 'sys' + 'user' < 'real', your computer is busy doing a lot of stuff in the
background. You probably have a printer plugged in, an ethernet or WiFi
connection active, a keyboard and mouse pointer being monitored, etc.. This is
normal on a modern computer,
Another explanation is that your query had to load or sync data from or
to the storage device, not just the OS cache. The "real" time increases
while waiting on IO, but "user" and "sys" do not (since the CPU is idle).
Dan.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users