Friday 2 June 2017

measure time taken for API call

I want to get the time taken for an API call.

i have a web application with angularJS front end and nodejs back end which has end to end connection.

route in back-end

app.get('/api/eventUploadRead', function(req, res) {
         filesReadUploads.find(function(err, events) {                
              if (err)
                  res.send(err);
              res.json(events);
          });
      });

service in front end which call the api

getUploadRead : function() {
        return $http.get('/api/eventUploadRead');
    },

controller

getEventsOfUploadedFile();
 $scope.events;
    function getEventsOfUploadedFile()
    {
        Event.getUploadRead()
        .success(function(event){
        $scope.events=event;
        })
            .error(function (error) {
                $scope.status = 'Unable to load event data: ';
        });
    }

what i want to do exactly is get the time spent until the data passed to the controller from the API call.t the reason to do this is,i want to measure the time change with the decrease of data load.i want to decrease data load and measure the time taken to load accordingly.

can anyone help me this?if not clear please let me know.

Thanks



via MSKP

No comments:

Post a Comment