Results 1 to 9 of 9

Thread: JS quesion!! Concerning my Bandwidth Measure project

  1. #1

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    JS quesion!! Concerning my Bandwidth Measure project

    To compare I use other Speed Testers to see how accurate mine is vs it is -while they can vary, mine is pretty accurrate until you have a higher speed. Then its off by Speed X 1.66320166 = Actual speed.

    https://github.com/jdc20181/SpeedTest

    Main.js is where you can see the code in the link above ^

    Note some of it was borrowed from a dead college project I found a while ago, and I brougt it back to life.

    I use the picture stored on another github respo which gave a increase amount of reliability, and accuracy.

    So - I guess I should get to my point used to it was only off by 1mb or less. with wifi my internet ran about 11.33mbps according to most and was about 10.68 mbps with mine -

    So what is the issue? I use a photo in bytes and basically download it to see how fast the speed is, which again is accurate with speeds up to a certain one...

    Thanks much!
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: JS quesion!! Concerning my Bandwidth Measure project

    Hi

    Only looked quickly.

    First thought is that the calculation is off in some way.

    Second, on looking, why is function showresults inside the measureconnectionspeed function?


    You are doing your calculations on reduced numbers (.tofixed(2)).
    Because you put it in part way through it loses some accurracy, this is then multipled as you reuse for the next calculation.
    Only put the tofixed bit when you display at the end, should solve it...

    Or make things worse

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: JS quesion!! Concerning my Bandwidth Measure project

    hmmm - The code is quite messy but i will def. take a look and consider those changes (and test them of course)
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  4. #4

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: JS quesion!! Concerning my Bandwidth Measure project

    Update 1 :

    I looked and you have a absolute valid point there - I see that its inside of another function maybe closing that function would make a difference?
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  5. #5

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: JS quesion!! Concerning my Bandwidth Measure project

    Update 2: I see now why its in the same "Function" it has to do with the ShowResults Function and this line:

    Code:
      var duration = (endTime - startTime) / 1000;
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  6. #6

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: JS quesion!! Concerning my Bandwidth Measure project

    Update 3: I reviewed the code, adn only seen the .tofixed at the end- I can't close the function off because of how it is used? Not sure how to go about fixing that one

    Each one is a different measurment - Bps/kbps/mbps

    That shows a more in depth analysis of your bandwidth speed.

    I will look into fixing that function you got me going crazy now haha
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  7. #7
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: JS quesion!! Concerning my Bandwidth Measure project

    I may be wrong but this bit :
    Code:
    function showResults() {
            var duration = (endTime - startTime) / 1000;
            var bitsLoaded = downloadSize * 8;
            var speedBps = (bitsLoaded / duration).toFixed(2);
            var speedKbps = (speedBps / 1024).toFixed(2);
            var speedMbps = (speedKbps / 1024).toFixed(2);
            ShowProgressMessage([
                "Your connection speed is:", 
                speedBps + " bps", 
                speedKbps + " kbps", 
                speedMbps + " Mbps",
                
            ]);
    }
    Perhaps should be
    Code:
    function showResults() {
            var duration = (endTime - startTime) / 1000;
            var bitsLoaded = downloadSize * 8;
            var speedBps = (bitsLoaded / duration);
            var speedKbps = (speedBps / 1024);
            var speedMbps = (speedKbps / 1024);
            ShowProgressMessage([
                "Your connection speed is:", 
                speedBps.toFixed(2) + " bps", 
                speedKbps.toFixed(2) + " kbps", 
                speedMbps.toFixed(2) + " Mbps",
            ]);
    }
    The fact showresults is inside the other, i can only guess is somewhere else in the js there is a MeasureConnectionSpeed.showResults()...
    Partial object orientation type thing.. But that is a guess...

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  8. #8

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: JS quesion!! Concerning my Bandwidth Measure project

    Good news:

    Its ~ 0.21 off from what another test showed on a different website

    Bad news is its still ~ 0.21

    Thanks for the tip - And I haven't read through some of the code because its messy to me, but I will, its been around for a few months I borrowed the code from a dead college project as mentioned in post #1 and brought it back to life.
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  9. #9

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: JS quesion!! Concerning my Bandwidth Measure project

    Update:

    I tested it once i added it to the main project and it is much faster, and shows more accurate results, not sure how that did that but thats amazing.
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width