speed-test-lib icon indicating copy to clipboard operation
speed-test-lib copied to clipboard

upload and download speed is off

Open ferily7 opened this issue 6 years ago • 1 comments

Hello,

I'm trying to calculate the upload and download speed using the function startUploadRepeat and startDownloadRepeat and converting it from bits to mbps. However, when I run my application and try to calculate the two speeds, the numbers are super off? The upload speed is like 0.1 and the download speed is in the 100 range. I'm using report.getTransferRateBit() to get the rate and dividing it by 1,000,000 but the numbers are still extremely off. Can anyone help me with this? Here is my code:

        SpeedTestSocket socketDown = new SpeedTestSocket();
        socketDown.startUploadRepeat(server.getUrl(),
                15000, 1000000, new IRepeatListener() {
                    @Override
                    public void onCompletion(final SpeedTestReport report) {
                        BigDecimal rate = report.getTransferRateBit();
                        BigDecimal divisor = BigDecimal.valueOf(1000000);
                        rate = rate.divide(divisor);
                        download.add(rate);
                        String rateString = "";
                        rateString = rateString + rate;
                        data.setDownload(rateString);
                        uploadData();
                        double num = 0.0000;
                        BigDecimal total = new BigDecimal(0.0000000);
                        for(BigDecimal value: download) {
                            num++;
                            total = total.add(value);
                        }
                        double dbTotal = total.doubleValue();
                        final double average = dbTotal / num;
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                TextView downText = findViewById(R.id.textViewTableDown);
                                downText.setText("" + average);
                                changeButton();
                            }
                        });
                        Log.v("test", "DOWNLOAD SPEED: " + rateString);

                    }

                    @Override
                    public void onReport(final SpeedTestReport report) {
                        BigDecimal rate = report.getTransferRateBit();
                        BigDecimal divisor = BigDecimal.valueOf(1000000);
                        rate = rate.divide(divisor);
                        download.add(rate);
                        String rateString = "";
                        rateString = rateString + rate;
                        data.setDownload(rateString);
                        Log.v("test", "DOWNLOAD SPEED, R: " + rateString);
                    }
                });

Also I'm putting all of this data in firebase, which is what the uploadData() function does. Any help will be greatly appreciated.

ferily7 avatar Aug 03 '18 17:08 ferily7

same after updating my phone to android 8.1.0

lr2bmail avatar Nov 18 '18 14:11 lr2bmail