Aniruddha Mukherjee
2012-Feb-20 13:21 UTC
[R] Time taken to process a file after a socket connection was made
Hello R people, I have created a '.csv' file of 100 rows by 20 columns whose each cell contains a random numbers between 0 & 1, thru a Java program. Once that is created a signal (just a letter) is send to the port of a socket connection at "localhost", which was earlier started by an "R" session. Now the "R" reads the '.csv' file into a data frame and calculates the average of 2000 numbers. This mean value was then written to the socket connection and Java received that successfully. The duration of this processing at "R" session took 1 min 03 seconds. My question : Is the time duration of 63 seconds OK for only this set of activities or it should be less? If so how it can be reduced? Point to be noted that both the Java and R were running on the same PC and the 62 seconds were consumed for the "readLines" command. Thanks and regards. Aniruddha. =====-----=====-----====Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you [[alternative HTML version deleted]]
ilai
2012-Feb-21 18:10 UTC
[R] Time taken to process a file after a socket connection was made
Aniruddha, Thank you, this is much more clear (and makes sense). Unfortunately I am out of my element here so I don't think I'll be much help, but see inline On Tue, Feb 21, 2012 at 4:14 AM, Aniruddha Mukherjee < aniruddha.mukherjee@tcs.com> wrote:> > > -- I ran the "socketConnection" command and the R session went into a > 'wait' state >-- In another window, I ran the Java code thru which the socket connection> was established and the 'R' prompt was back >-- Now in the meantime, the Java code has written a line onto the socket> whereby a letter, say '*d*', was sent > -- I ran the "readLines" command at 'R' prompt and after waiting for *61*seconds, it displayed the ' > *d*'. > -- Again later, in a next trial, I sent a matrix of 20,000 values (in > 1,000 rows & 20 cols) from Java and that took almost the same time (*62*sec.) by the 'readLine' commandOK. So that is much clearer. I think, contrary to your statement in the original post, it is not readLines taking up the 60 sec, but something with the communication. Since you get an answer eventually, it must be listening, and if you opened the connection with default, it should not be blocking either (no timeout)... Like I said I don't have much to add but maybe try readLines(connection,n=1000) I wouldn't think it matters, but maybe explicitly declaring the number of lines to read will speed it up because R is waiting for more input and only after 60 sec it times out and reads what's available ? again, the default is blocking=FALSE, but... Second, make sure the connection is established (ready to read/write): socketSelect(list(conname,conname),c(F,T),timeout=0) Bottom line, I have no idea what is going on except 60 sec doesn't sound right to me... Good luck Elai> > Here lies my query : Is there any kind of "*timeout*" factor which is > causing the delay? > Please share your thought. > Also do you think that instead of *socketConnection & readLines*, *make.socket > & read.socket* would perform better? > > Thanks and regards. > Aniruddha. > > > From: ilai <keren@math.montana.edu> To: Aniruddha Mukherjee < > aniruddha.mukherjee@tcs.com> Date: 02/21/2012 10:42 AM Subject: Re: [R] > Time taken to process a file after a socket connection was made Sent by: > ilaik9@gmail.com > ------------------------------ > > > > That sounds very strange. Are you sure readLines consumed 63 sec for > 2000 vals ? doubt it. When you say "...started by an "R" session..." > does it imply the R session actually doing the work is already up and > running ? a shot in the dark, but maybe the 60 sec are the time for R > to load on your machine (even though that's still 10 times what I'd > expect from my dino)? Did you test the R part of it directly ? i.e. > could you post the result from an open R session or running a batch > script starting with readLines ? > see ?system.time or ?proc.time if you need them. > BTW hope this is just a test and you're not firing up R just to > calculate a mean... > > Cheers > > > On Mon, Feb 20, 2012 at 6:21 AM, Aniruddha Mukherjee > <aniruddha.mukherjee@tcs.com> wrote: > > Hello R people, > > > > I have created a '.csv' file of 100 rows by 20 columns whose each cell > > contains a random numbers between 0 & 1, thru a Java program. Once that > is > > created a signal (just a letter) is send to the port of a socket > > connection at "localhost", which was earlier started by an "R" session. > > Now the "R" reads the '.csv' file into a data frame and calculates the > > average of 2000 numbers. This mean value was then written to the socket > > connection and Java received that successfully. The duration of this > > processing at "R" session took 1 min 03 seconds. > > My question : Is the time duration of 63 seconds OK for only this set of > > activities or it should be less? If so how it can be reduced? Point to be > > noted that both the Java and R were running on the same PC and the 62 > > seconds were consumed for the "readLines" command. > > > > Thanks and regards. > > Aniruddha. > > =====-----=====-----====> > Notice: The information contained in this e-mail > > message and/or attachments to it may contain > > confidential or privileged information. If you are > > not the intended recipient, any dissemination, use, > > review, distribution, printing or copying of the > > information contained in this e-mail message > > and/or attachments to it are strictly prohibited. If > > you have received this communication in error, > > please notify us by reply e-mail or telephone and > > immediately and permanently delete the message > > and any attachments. Thank you > > > > > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > >[[alternative HTML version deleted]]