title: how to get exact run time of r code?
body: <p>In my code the input taken at run time.if time delay in entering data also showing as my runtime.How to remove user interaction time from code?</p>
  
  <p>Sample code.if i call fun(),readline take value at run time.value of " Answer " entering delay also included in run time.how  remove user entering delay from run time ?</p>
  
  <pre><code>fun &lt;- function() {
  start.time &lt;- Sys.time()
  i&lt;-1
  ANSWER &lt;- readline("Are you a satisfied R user? ")
  while(i&lt;1000){
  sink("D://newdatset.txt")
  print(ANSWER)
  sink()
  i&lt;-i+1}
  unlink("D://newdatset.txt")
  if (substr(ANSWER, 1, 1) == "n")
  cat("This is impossible.  YOU LIED!\n")
  else
  cat("I knew it.\n")
  end.time &lt;- Sys.time()
  time.taken &lt;-end.time - start.time 
  time.taken
  </code></pre>
  
  <p>}</p>
  
  <p>if i call fun(y).get the correct answer .</p>
  
  <pre><code>fun &lt;- function(x) {
  start.time &lt;- Sys.time()
  i&lt;-1
  ANSWER &lt;- "x"
  while(i&lt;1000)
  {
  sink("D://NH.txt")
  print(ANSWER)
  sink()
  i&lt;-i+1}
  if (substr(ANSWER, 1, 1) == "n")
  cat("This is impossible.  YOU LIED!\n")
  else
  cat("I knew it.\n")
  end.time &lt;- Sys.time()
  time.taken &lt;-end.time - start.time 
  print( time.taken)}
  </code></pre>