First get the start timestamp as follows. This is the current time in milliseconds.
var start = new Date().getTime();
Then do your processing and substract start from the current time in millseconds.
var elapsed = new Date().getTime() - start;
This will give you the time taken between the two points in time in milliseconds.