show timing information in xhr.post/json

This commit is contained in:
Andrew Dolgov 2021-03-03 09:56:35 +03:00
parent 3b67abb0ea
commit adf7189e94
1 changed files with 5 additions and 2 deletions

View File

@ -154,7 +154,10 @@ String.prototype.stripTags = function() {
/* exported xhr */ /* exported xhr */
const xhr = { const xhr = {
_ts: 0,
post: function(url, params = {}, complete = undefined, failed = undefined) { post: function(url, params = {}, complete = undefined, failed = undefined) {
this._ts = new Date().getTime();
console.log('xhr.post', '>>>', params); console.log('xhr.post', '>>>', params);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -171,7 +174,7 @@ const xhr = {
reject(error); reject(error);
}, },
load: function(data, ioargs) { load: function(data, ioargs) {
console.log('xhr.post', '<<<', ioargs.xhr); console.log('xhr.post', '<<<', ioargs.xhr, (new Date().getTime() - xhr._ts) + " ms");
if (complete != undefined) if (complete != undefined)
complete(data, ioargs.xhr); complete(data, ioargs.xhr);
@ -197,7 +200,7 @@ const xhr = {
reject(e); reject(e);
} }
console.log('xhr.json', '<<<', obj); console.log('xhr.json', '<<<', obj, (new Date().getTime() - xhr._ts) + " ms");
if (obj && typeof App != "undefined") if (obj && typeof App != "undefined")
if (!App.handleRpcJson(obj)) { if (!App.handleRpcJson(obj)) {