hypery2k / cordova-hotspot-plugin

A Cordova plugin for managing HotSpot networks on Android
MIT License
37 stars 49 forks source link

getAllHotspotDevices - Performance optimization #29

Closed webmaster-imaginet closed 8 years ago

webmaster-imaginet commented 8 years ago

I have performance issues with getHotspotDevices

To show this, I change a little bit your sample app controller.

Here is the code:

.controller('DevicesCtrl', function ($scope, $interval) { "use strict"; var init = function () {

$scope.data = {};
$scope.data.clockTime = 0;
$scope.data.clock = $interval(function(){
    $scope.data.clockTime ++;
    console.log('%c%s','font-size:14px;color:green;',"Sec: " + $scope.data.clockTime);
}, 1000);

  console.log('%c%s','font-size:20px;color:red;',"START: " + $scope.data.clockTime);
      cordova.plugins.hotspot.getAllHotspotDevices(
        function (response) {
          console.table(response);
          $scope.devices = response;
            console.log('%c%s','font-size:20px;color:red;',"STOP: " + $scope.data.clockTime);
            $interval.cancel($scope.data.clock);
        }, function () {
          alert('Device listing failed.');
        }
      );
};

// init controllers
//init();

// API
$scope.refresh = function () {
  init()
};

it took 108 second to get the devices list

image

I filmed a video to show you the problems. https://www.dropbox.com/s/msofovh7w58u7ft/hotspot_plugin_slow.mp4?dl=0

hypery2k commented 8 years ago

please try if the current master is acceptable. Could not really reduce it more due to technically restrictions

webmaster-imaginet commented 8 years ago

I used version 1.1.2 (cordova plugin add cordova-plugin-hotspot) I also try version 1.1.1 (cordova plugin add cordova-plugin-hotspot!1.1.1) but got the same "slow" results.

now I try to use the git "master" as you asked (cordova plugin add https://github.com/hypery2k/cordova-hotspot-plugin.git) but got empty array

image

hypery2k commented 8 years ago

Should be better with 1.1.3

webmaster-imaginet commented 8 years ago

Much faster...

image

But why reading the arp file is not working super fast?

Is it will be faster to read the file and send as callBack the result "AS IS" and then do the divide to IP & MAC in the javascript? If the answer is yes, maybe is good idea to add a new methood for that?

hypery2k commented 8 years ago

the ARP my not contain all devices. But I optimize the method more

webmaster-imaginet commented 8 years ago

Good! This is still ver 1.1.3 (from the NPM) or will be 1.1.4?

hypery2k commented 8 years ago

will be 1.1.4 But I'll wait if any other issue comes up before releasing next version

hypery2k commented 8 years ago

Released version 1.1.4