How to measure time spent on socket read() method ?

Hi,
I have a socket waiting for input stream from a remote host :
// method blocks until some input is available
int count = socket_host.getInputStream().read(bytes);
I want to know how much time it took to receive "count" bytes from remote host.
          t1 = System.nanoTime();
          int count = socket_host.getInputStream().read(bytes);
          t2 = System.nanoTime();
(t2-t1) of course is not the answer, because t1 needs to start when read method actually stop waiting..
I need some kind of call back, in order to know when input starts coming..
how would you do that accuratly ?
thanks for help !!

thanks ejp , I followed your idea :
     count1=socket_host.getInputStream().read(bytes,0,1);
     t1 = System.nanoTime();
     count2=socket_host.getInputStream().read(bytes,1,bytes.length-1);
     t2 = System.nanoTime();
     if (count1==1 && count2>0)
          count=count2+1;
     else if (count1==-1 || count2==-1)
          count=-1;After I compute speed (with t2-t1 and count given to that method)
     public static double computeSpeed(double nanosec,double nbbytes){
          if (nanosec==0)
               return 0;
          double speedkilobytespersec=nbbytes/nanosec*1000000;
          return speedkilobytespersec;
     }But speed results are very erratic and sometimes superior to 100 MBytes /sec , which is not possible with my connection.
Somehow, I have the feeling that when t1 is triggered, it is already too late, many bytes are already arrived, and results is not accurate.
It would need a lower level trigger, wouldn't it ?
thanks

Similar Messages

  • How to get time spent in the repaint(long delay) method of component?

    Hi,
    I'm trying to get the time spent in the repaint method of Component. I tried to surround the method with time information:
    long time = System.getTime();
    component.repaint(400);
    time = System.getTime() - time;
    System.out.println("Time spent in repaint is: " + time);
    But, the method seem to return about immediatly after call, whereas the display do not seem to be completly redrawn. I think that this is because repaint method is done in a separate thread....
    I thought to catch the event that could be thrown when redrawn is completed but could not find this event....
    Do you have an idea how I could perform this?
    Thanks a lot
    Tanguy

    repant() posts an event to the Event Queue so that sometime soon the component's paint() mehtod will be called. It will be called by the Event Thread.

  • Measuring time spent logged in

    Hi,
    Is there a way to measure how much time each user is logged into our family computer per day? Each person has a separate account and there is also an administrator account. We have 10.5.
    I was looking for a widget or clock that would run on the desktop to show elapsed time spent logged in. The parental controls might provide another option.
    Thanks

    Thanks for your continued help. I had already looked through the widget list before, and I looked through them carefully again. I'm looking for a widget that just measures the time a person is logged into their account and displays that time in a small digital window. I'd like it to start automatically when a person logs on. This will help our family members get a grip on just how many hours we actually spend on the computer.
    We tried a widget that measures uptime, but that is a running total, even when the computer is asleep.
    If there isn't currently a widget that does this, can I send the idea to someone who knows how to create it?
    Thanks for your help.

  • How to Measure time taken for a some lines of code in a program?

    Hi
    I have one requirement to measure time taken for executing a  block of code in report . How we can find it ?
    Is there any way to code something in report to caluculate it ?
    Please send solution as early as possible
    thank u

    Ok.. try this code...
    DATA : t1 TYPE i,
    t2 TYPE i,
    delta(16) TYPE p.
    GET RUN TIME FIELD t1.
    PERFORM get_data. "your block of code
    GET RUN TIME FIELD t2.
    delta = t2 - t1.
    delta = delta / 1000000.
    WRITE :/ 'Time elapsed : ', delta , 'Secs'. "time in secs.

  • Measure time spent up to the display of ADG...

    Hi guys,
    I want to measure the time spent up to the diplay of my Advanceddatagrid component.
    1. We take a timestamp in application-preinitialize event
    2. Cannot find the latest point just before the ADG diplayed to the user. (i.e. after: applicationCompleted, updateCompleted, the item rendering is finish, ...)
    Anyone know where I can take this latest timestamp before ADG got display to the user?
    Thanks,
    Alain

    That helped thanks-
    I was able to solve this by deleting all "Envelop Index*"- and "ExternalUpdates*"-files in ~/Library/Mail/v2/MailData. After that I restarted Mail and let it reindex all mailboxes.

  • How to measure time in labview?

    Hello,
    I am using PCI-DAS card for Analog Input and Digital Output.
    In the Analog Input for the voltage measurement labview takes near
    about 1 second.But i want to reduce that time...means it has to take
    one reading only in some miliseconds and there is no loops nothing
    complicated just simple functions r there and as i run the vi it shows
    one voltage reading.
    I dont know how to reduce time period in this case.
    And another thing is that i am saying this 1 second as per my
    watch.but i want Labview itself shows the total time taken for the
    execution.
    Anybody knows about it please mail me and post the answer.
    Thanking You
    Safdar...

    In general AI, attached example should work (i.e. 6025E).
    This is however, an example for your reference only.
    Best regards
    ian
    Ian F
    Since LabVIEW 5.1... 7.1.1... 2009, 2010
    依恩与LabVIEW
    LVVILIB.blogspot.com
    Attachments:
    example_AI_20041110.vi ‏51 KB

  • How to use time stamps en how to make time stamps in Adobe Reader

    How to use time stamps en how to make time stamps in Adobe Reader

    Did you find a solution? I am having the same problem.
    PDF compatibility level is too high. Supported PDF versions are PDF 1.3 and PDF 1.4 (Acrobat 4, 5 and 6). If you are using Acrobat 7 or higher you will need to save your file at a lower PDF compatibility level.

  • Query Performance Issue - Max time spent on DB read

    Hi Experts,
    We have a big query which is having two levels and it is pulling data from 10 underlying cubes which have different sales organizations in each. Due to design of the query and amount of data in cubes the maximum time is being spent on DB read. Now we have checked the trace of the query execution and we have seen that the system goes and check , say a Cube A even when it does not contain data for the sales org that is requested by the user. Please note that we have mandatory selection for Sales org on the Level 1 query.
    In order to resolve this issue we have maintained entry of SALESORG in the RRKMULTIPROVHINT table, but on running the trace again we are seeing that for Level 2 query the system is still querying the cubes which do not contain the data for the sales org requested by the user there by increasing the run time of the query many folds. Can you please help us out if you have faced similar issue?
    Regards,
    Prashant Shah

    I think your Query data selection is expecting data from all the cubes. You have to analyze right from the Query definition and the variables selection to know further.
    Please put "H" for your MP in RSDIPROP t-code and choose H in Query read mode in RSRT-->Properties.

  • How to measure time delayed measurement

    Hi All:
    I am using TDS3064 scope to measure time delay betwwen two channels (using IVI driver
    complience package 2.2 for scope IVI driver). I look through drivers, but not able to find
    delayed measurement function. Is there any alternate way to measure time delay betwwen two
    channels. If possible please provide me example. I am new to LV programming.
    Thanks
    DBhagat

    You have to understand something about IVI class drivers. To support portability, those functions that are common to a class are what you see in the driver. Some scopes might have the ability to measure time delay between trigger points on different waveforms but many don't. If there is such a function supported by your scope, then you can make a call to the instrument specific driver or a VISA Write/Read. Of course, you then loose the portability feature of IVI which, imho, is about the only reason to use IVI class drivers. What I would recomend is that you do a capture of both traces and then do an analysis of the raw data in LabVIEW. One way to do this is with Trigger Detection for 1 Channel (Analyze>Waveform Monitoring palette). Wire each channels data to the function and obtain the time for each trigger event. The function will return the time for each event that you can use to calculate the difference.

  • How to measure time intervals

    Hello!
    I am sorry to bother this forum, but I haven't
    found any faq for this group at faqs.org. Here is
    my problem:
    I have received a computer with LabView installed
    and 2 DAQ cards (unfortunatelly, with no books).
    I have built a program wich does few simple
    tasks - it measures temerature from 4 different
    channels at 100 measures/sec, plots it and writes
    it to a file. I use 4 "AI aquire wavform"
    instruments and not 1 multiple instrument. Now, I
    would like to measure somehow the actual
    intervals between the measures, if possible,
    relative to the time that I press the start
    button. I was not able to find how to do it, and
    I would appreciate any help. Thank you
    P.S. I would be very thankful if the cc of the
    answer (if there
    is one) will be sent to my e-
    mail - I do not always have access to the
    usegroups.
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    Ok.. try this code...
    DATA : t1 TYPE i,
    t2 TYPE i,
    delta(16) TYPE p.
    GET RUN TIME FIELD t1.
    PERFORM get_data. "your block of code
    GET RUN TIME FIELD t2.
    delta = t2 - t1.
    delta = delta / 1000000.
    WRITE :/ 'Time elapsed : ', delta , 'Secs'. "time in secs.

  • How to measure time?

    how can i mesaure the time that took to execute a function?
    thanks

    how can i mesaure the time that took to execute a
    function?
    thanks
    Usually the end time minus the start time. How do you think? This probably won't tell you much though.

  • How to measure time difference between zero crossing of a sine wave and rise time of a pulse on a same graph?

    I have a 50Hz sine wave and a pulse signal on a same graph. The phase difference between two is between 0-90 degrees.
    Now I need to calculate the time difference between (when the sine wave crosses zero volts) and (when the pulse rises). The frequency will stay approximately same for both signals.
    The application is for a three phase generator. In simple words, when the time difference between the zero-crossing of sine wave and the pulse rises increases, that means that the load on the generator has increases.
    I am a beginner user of LabView (version 9, 2009), maybe it is a very simple problem but I've been pulling my hair out for the last few days and coudln't figure anything out. Any help would be greatly appreciated. I am using DAQ USB-6008 to measure these voltages and pulse from the generator and a sensor
    I have attached a jpg (a graph that i just made with excel to explain). The time 't' is what I am trying to measure
    Cheers
    Awais 
    Message Edited by awais.h on 03-30-2010 11:20 PM
    Message Edited by awais.h on 03-30-2010 11:21 PM
    Solved!
    Go to Solution.

    Hi
    Thanks for the code but I'm afraid it won't work. Like you said the probability of choosing a value that is on both graphs may not happen. This is something that I would like the code to do automatically.
    But I did use the previous code posted and made some modifications to it and it seems to work perfectly. Now the next thing is to be able to get just that one value that tells you the first time difference.
    Here is what I get using that code.
    As you can see from the t Values. I only need the one that is highlighted. If there is a way to filter out the rest it would be great.
    I was thinking of a while loop and as soon as the value is higher than 3E-5 it would store the number and stop the loop, but I'm not too familiar with arrays in labview.
    Here is the the code modified.
    As you can see, it wasn't that big of a modification and it still is your code.
    I will keep trying.
    Thanks for the help
    Attachments:
    FinalShockSpeed.vi ‏55 KB

  • How to measure time difference between two continous encoder pulse (PULSE A & PULSE B)

    im trying to figure out the time difference between two square
    wave pulse (PULSE A and PULSE B) from an encoder. I tried to modify many code but fail to capture thephase difference  for each pulse. the
    pulse only rise to 5V and fall to 0V like normal square wave pulse
    can you and all of experts here help me out with this?
    my problem
    1) Encoder pulse are continous (pulse A and pulse B)
    2) Square wave pulse have "0V" and "5V" please rapidly
    if possible someone show me correct method , Im using LABVIEW 7.1 and Hardware NI SCOPE (PCI 5102)
    your advice are highly appreciated
    among my idea as in attachment , but I failed to get it
    Attachments:
    Need to Get this wave.JPG ‏34 KB

    Hi Amirul,
    Check the attached JPG file. i think this will be use full to you
    Regards,
    Santhosh M

  • Java.sql.SQLException: Io exception: Socket read timed out

    Hello,
    I've a interface RFC - JDBC - RFC.
    When this interface is executing, i have the follow error in RuntimeWorkbench::
    'Unable to execute statement for table or stored procedure. 'TABLAERR' (Structure 'STATEMENT') due to java.sql.SQLException: Io exception: Socket read timed out'
    In SXMB_MONI do not see any message, only
    '  <SAP:Category>XIAdapterFramework</SAP:Category>
      <SAP:Code area="MESSAGE">GENERAL</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException</SAP:AdditionalText>
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack />
      <SAP:Retry>M</SAP:Retry> '
    this error don't occurs always, when and why i don't know..
    I searched for information about this error and nothing found
    why it is happens?
    thank very much

    HI,
    This is not a problem in ur mapping or configuration.
    This is a problem with JDBC connection. This is a common error, that generally comes when the DB server is receiving and processing numerous records. Connection time out or socket read time out.
    First try this:
    In ur JDBC adapter go to Advanced Tab Page and check Transaction Isolation Level as Serializable.
    If still problem persists then take help of basis guys and increase the timeout for the connection, same thing can be asked from DB team.

  • Problems in read method

    I have a method which run every 1 minutes to read data from other application. The read() method is used and it blocks until at least a byte is available. Some websites sugguest using thread.sleep + while....but if i use timer + timertask with the read() method....will it a bad coding?
    Thanks

    I'd use TimerTask/Timer. From the sounds of it scheduling is not this classes job - reading the data is.

Maybe you are looking for

  • Sept. 10 - No Phone Service still reported Aug 30 Medical Emergency

    My parents are in their 90's and Mom is blind. We reported their outage on 8/30.  It was marked a Medical Emergency and were promised that the repair would be highest priority  - what a joke!!!!   We were told and texted that the repair would happen

  • Time machine gets stuck on indexing

    Since the last weeks my time machine will not backup anymore.. I have searched around but couldn't find out what will fix it.. This is what the module had to say: Starting standard backup Attempting to mount network destination using URL: afp://admin

  • How can i set up lightroom for tethered shooting with an eithernet cable

    So I have my Nikon d4 set up with Nikon Picture control so that it will download to my laptop with an Ethernet cable but it downloads to a file on the hard drive - I can choose what file, etc but what I want to do is take advantage of Lightrooms teth

  • Charge uk iPad in USA

    iPad - power. Based in UK 220/240v power. Going to USA 110v power. Is there a  built in transformer in the iPad or iPad cable?  I.e. Can I just use a plug adapter to accommodate the different plug point/prongs? Grateful for any clarification, thank y

  • Report CSS not working after upgrade

    I have been researching this issue for days with no luck.  I recently upgraded a project from VS2008 to VS1013.  During this process, I downloaded and installed the 13.0.10 installer.  Everything seems to work great except for the CSS functionality o