Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 34 of 34

Thread: Average length of time for input/output

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Average length of time for input/output

    The start and stop times are not associated with the items. If two items are added before one is removed, the start time for the first item is lost. When the first item added is removed, its start time will be the time for the last item that was added, not the time that it was added.
    If you don't understand my answer, don't ignore it, ask a question.

  2. #27
    Member
    Join Date
    Nov 2012
    Posts
    49
    My Mood
    Amused
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: Average length of time for input/output

    Is that in the one with the Timer class?

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Average length of time for input/output

    I'm talking about this statement:
    		startTime = System.currentTimeMillis(); // ***** GET TIME *****

    I don't see any use of the Timer class in the posted code.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #29
    Member
    Join Date
    Nov 2012
    Posts
    49
    My Mood
    Amused
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: Average length of time for input/output

    Quote Originally Posted by Norm View Post
    I'm talking about this statement:
    Producer	
                    startTime = System.currentTimeMillis(); // ***** GET TIME *****
     
    consumer
                    stopTime = System.currentTimeMillis(); // ****** GET TIME ******
                    totalTime +=(stopTime-startTime);

    I don't see any use of the Timer class in the posted code.
    Yeah, I changed it earlier but site crashed, so ,wasn't sure which one you seen.

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Average length of time for input/output

    If the start time is NOT saved with the item, then there will only be one value in the program. There needs to be a starttime saved for EACH ITEM.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #31
    Member
    Join Date
    Nov 2012
    Posts
    49
    My Mood
    Amused
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: Average length of time for input/output

    So, I need another long to add all the time between inserts and removes together and then divide it by the outs?

            stopTime = System.currentTimeMillis(); // ****** GET TIME ******
            long measurement +=(stopTime-startTime);
    	totalTime = totalTime + measurement;

    Is this what you mean?

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Average length of time for input/output

    No. There needs to be a class that holds the item's value and start time so that the start time is with the item.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #33
    Member
    Join Date
    Nov 2012
    Posts
    49
    My Mood
    Amused
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: Average length of time for input/output

    Oh ok, I'll give that a try.

    Cheers.

  9. #34
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Average length of time for input/output

    Quote Originally Posted by ManInTheMiddle View Post
    ...I'v edited it again and went about it a different angle but now...
    Any time you edit code, please post the new version with your new question so we all see the same code, especially if you go about it from a different angle.


    Quote Originally Posted by ManInTheMiddle View Post
    I'm down to a single error in run time NullPointerException in Thread-2
    Paste the full text of any error messages with your code and question so we can easily offer help.



    :/ I guess there was another page I didn't read yet... Perhaps your problem has been fixed.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 0
    Last Post: March 28th, 2013, 06:27 AM
  2. Input/Output help if possible
    By rossonomous in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 13th, 2011, 01:05 PM
  3. How do i limit the input time
    By itayj in forum Java Theory & Questions
    Replies: 6
    Last Post: October 24th, 2011, 03:47 PM

Tags for this Thread