Dear Matthew,<br><br> I did do some research on the internet about,interpreting the statistics returned by time.<br><br>In this discussion [1],I read the following paragraph :-<br><br><code>User+Sys</code> will tell you how much actual CPU time your 
process used.  Note that this is across all CPUs, so if the process has 
multiple threads it could potentially exceed the wall clock time 
reported by <code>Real</code>.  Note that in the output these figures include the <code>User</code> and <code>Sys</code>
 time of all child processes as well, although the underlying system 
calls return the statistics for the process and its children separately.<br><br><br><br>So when I compute user + sys for the following ( from my prev email ) 2 items <br><br>&gt; rbind(time.data.table[[1]],<div class="im">
time.data.table[[2]])<br>
     user.self sys.self elapsed user.child sys.child<br></div>[1,]     0.008        0   0.005          0         0<br>[2,]     0.004        0   0.005          0         0<br><br>&gt; rbind(time.data.table[[1]],<div class="im">
time.data.table[[2]])<br>
     user.self sys.self elapsed user.child sys.child<br></div>[1,]     0.004    0.004   0.005          0         0<br>[2,]     0.009    0.000   0.005          0         0<br><br>I see it &quot;swinging&quot; both ways. <br>
<br><br>[1] <a href="http://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1">http://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1</a><br>
<br>Thank you,<br>Ashim<br><br><div class="gmail_quote">On Tue, Nov 29, 2011 at 1:42 PM, Matthew Dowle <span dir="ltr">&lt;<a href="mailto:mdowle@mdowle.plus.com">mdowle@mdowle.plus.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
I don&#39;t follow. The elapsed time is 0.005 seconds in all cases. The<br>
times are extremely small anyway (5ms), it seems to be just noise.<br>
<br>
We&#39;re used to seeing examples like the one in the examples section of<br>
help(&quot;:=&quot;) where 591s is reduced to 1.1s. A 500 times speedup. But, more<br>
importantly, where the wall clock time (10 minutes) is meaningful, worth<br>
saving, and (hopefully) the readers understand the saving scales; i.e.,<br>
10 minutes saving can easily be hours with larger data.<br>
<br>
We can talk on the 5ms scale, too, but you&#39;ll need to be much more<br>
precise and read up on the subject first, please.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, 2011-11-29 at 10:56 +0530, Ashim Kapoor wrote:<br>
&gt; Dear Matthew,<br>
&gt;<br>
&gt; Many thanks for your email.<br>
&gt;<br>
&gt; Following your advice I split out the as.character(as.hexmode( )) and<br>
&gt; ran it many times. The results swing both ways.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; &gt; library(xtable)<br>
&gt; &gt; library(data.table)<br>
&gt; &gt; start.size&lt;-6e+5<br>
&gt; &gt;<br>
&gt; &gt; time.data.table&lt;-list()<br>
&gt; &gt;<br>
&gt; &gt; for (i in 0:1){<br>
&gt; + n&lt;-start.size*10^i<br>
&gt; + n1&lt;-n/5000<br>
&gt; +<br>
&gt; my.data.table&lt;-data.table(index=1:n,seriesname=rep(as.character(as.hexmode(1:n1)),each=5000),value=rnorm(n))<br>
&gt; + setkey(my.data.table,&quot;seriesname&quot;)<br>
&gt; + searchitem&lt;-as.character(as.hexmode(n1))<br>
&gt; + time.data.table[[i+1]]&lt;-system.time(my.data.table[J(searchitem)])<br>
&gt; + }<br>
&gt; &gt;<br>
&gt; &gt; rbind(time.data.table[[1]],time.data.table[[2]])<br>
&gt;      user.self sys.self elapsed user.child sys.child<br>
&gt; [1,]     0.008        0   0.005          0         0<br>
&gt; [2,]     0.008        0   0.005          0         0<br>
&gt;<br>
&gt; &gt; rbind(time.data.table[[1]],time.data.table[[2]])<br>
&gt;      user.self sys.self elapsed user.child sys.child<br>
&gt; [1,]     0.008        0   0.005          0         0<br>
&gt; [2,]     0.004        0   0.005          0         0<br>
&gt;<br>
&gt; &gt; rbind(time.data.table[[1]],time.data.table[[2]])<br>
&gt;      user.self sys.self elapsed user.child sys.child<br>
&gt; [1,]     0.004        0   0.005          0         0<br>
&gt; [2,]     0.004        0   0.005          0         0<br>
&gt;<br>
&gt; &gt; rbind(time.data.table[[1]],time.data.table[[2]])<br>
&gt;      user.self sys.self elapsed user.child sys.child<br>
&gt; [1,]     0.008        0   0.005          0         0<br>
&gt; [2,]     0.008        0   0.005          0         0<br>
&gt;<br>
&gt; &gt; rbind(time.data.table[[1]],time.data.table[[2]])<br>
&gt;      user.self sys.self elapsed user.child sys.child<br>
&gt; [1,]     0.004    0.004   0.005          0         0<br>
&gt; [2,]     0.009    0.000   0.005          0         0<br>
&gt;<br>
&gt; Thank you,<br>
&gt; Ashim<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Nov 28, 2011 at 4:53 PM, Matthew Dowle<br>
&gt; &lt;<a href="mailto:mdowle@mdowle.plus.com">mdowle@mdowle.plus.com</a>&gt; wrote:<br>
&gt;<br>
&gt;         Hi,<br>
&gt;         Welcome to the list. Quick first response..<br>
&gt;<br>
&gt;         Comparing differences of 4ms of single runs is not usually<br>
&gt;         very robust due<br>
&gt;         to overhead and cache effects. We usually prefer differences<br>
&gt;         of many<br>
&gt;         seconds or minutes and even then take the minimum of 3<br>
&gt;         repeated runs,<br>
&gt;         using something like packages rbenchmark or microbenchmark.<br>
&gt;<br>
&gt;         as.character(as.hexmode()) will install those strings in R&#39;s<br>
&gt;         global string<br>
&gt;         cache. The 2nd time will be faster as all those strings are<br>
&gt;         already<br>
&gt;         cached.  Whether that explains this case I don&#39;t know, seems<br>
&gt;         plausible as<br>
&gt;         it&#39;s only 4ms. That part could be split out, repeated and<br>
&gt;         timed<br>
&gt;         separately.<br>
&gt;<br>
&gt;         Think a simpler example would be possible, too. I missed the<br>
&gt;         reason why<br>
&gt;         it&#39;s in a loop through 0:1 and for 4ms something like that<br>
&gt;         might be making<br>
&gt;         a tiny difference.<br>
&gt;<br>
&gt;         HTH, Matthew<br>
&gt;<br>
&gt;         &gt; Dear all,<br>
&gt;         &gt;<br>
&gt;         &gt; Please see my reproducible example below. My question is why<br>
&gt;         does the 2nd<br>
&gt;         &gt; table,which is bigger have a smaller access time ?<br>
&gt;         &gt;<br>
&gt;         &gt;&gt; library(xtable)<br>
&gt;         &gt;&gt; library(data.table)<br>
&gt;         &gt; data.table 1.7.2  For help type: help(&quot;data.table&quot;)<br>
&gt;         &gt;&gt; start.size&lt;-6e+5<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;&gt; time.data.table&lt;-list()<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;&gt; for (i in 0:1){<br>
&gt;         &gt; + n&lt;-start.size*10^i<br>
&gt;         &gt; + n1&lt;-n/5000<br>
&gt;         &gt; +<br>
&gt;         &gt;<br>
&gt;         my.data.table&lt;-data.table(index=1:n,seriesname=rep(as.character(as.hexmode(1:n1)),each=5000),value=rnorm(n))<br>
&gt;         &gt; + setkey(my.data.table,&quot;seriesname&quot;)<br>
&gt;         &gt; +<br>
&gt;         &gt; time.data.table[[i<br>
&gt;         +1]]&lt;-system.time(my.data.table[J(as.character(as.hexmode(n1/4))),])<br>
&gt;         &gt; + }<br>
&gt;         &gt;<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;&gt; rbind(time.data.table[[1]],time.data.table[[2]])<br>
&gt;         &gt;      user.self sys.self elapsed user.child sys.child<br>
&gt;         &gt; [1,]     0.008        0   0.008          0         0<br>
&gt;         &gt; [2,]     0.004        0   0.004          0         0<br>
&gt;         &gt;&gt; time.data.table[[1]]<br>
&gt;         &gt;    user  system elapsed<br>
&gt;         &gt;   0.008   0.000   0.008<br>
&gt;         &gt;&gt; time.data.table[[2]]<br>
&gt;         &gt;    user  system elapsed<br>
&gt;         &gt;   0.004   0.000   0.004<br>
&gt;         &gt;&gt;<br>
&gt;         &gt;<br>
&gt;         &gt; Many thanks,<br>
&gt;         &gt; Ashim<br>
&gt;<br>
&gt;         &gt; _______________________________________________<br>
&gt;         &gt; datatable-help mailing list<br>
&gt;         &gt; <a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
&gt;         &gt;<br>
&gt;         <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
</div></div></blockquote></div><br>