mirror of
https://github.com/svg/svgo.git
synced 2025-07-31 07:44:22 +03:00
lib/svgo: store elapsed time in result object
This commit is contained in:
@ -10,18 +10,22 @@ svgo
|
|||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
// output:
|
/*
|
||||||
// {
|
output:
|
||||||
// // optimized SVG data string
|
|
||||||
// data: '<svg width="10" height="20">test</svg>'
|
{
|
||||||
// // additional info such as width/height and start/end bytes length
|
// optimized SVG data string
|
||||||
// info: {
|
data: '<svg width="10" height="20">test</svg>'
|
||||||
// width: '10',
|
// additional info such as width/height and start/end bytes length
|
||||||
// height: '20',
|
info: {
|
||||||
// inBytes: 59,
|
width: '10',
|
||||||
// outBytes: 38
|
height: '20',
|
||||||
// }
|
inBytes: 59,
|
||||||
// }
|
outBytes: 38,
|
||||||
|
time: N
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
})
|
})
|
||||||
// end promises chain
|
// end promises chain
|
||||||
|
@ -15,18 +15,22 @@ svgo
|
|||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
// output:
|
/*
|
||||||
// {
|
output:
|
||||||
// // optimized SVG data string
|
|
||||||
// data: '<svg width="10" height="20">test</svg>'
|
{
|
||||||
// // additional info such as width/height and start/end bytes length
|
// optimized SVG data string
|
||||||
// info: {
|
data: '<svg width="10" height="20">test</svg>'
|
||||||
// width: '10',
|
// additional info such as width/height and start/end bytes length
|
||||||
// height: '20',
|
info: {
|
||||||
// inBytes: 59,
|
width: '10',
|
||||||
// outBytes: 38
|
height: '20',
|
||||||
// }
|
inBytes: 59,
|
||||||
// }
|
outBytes: 38,
|
||||||
|
time: N
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
})
|
})
|
||||||
// end promises chain
|
// end promises chain
|
||||||
|
@ -10,18 +10,22 @@ svgo
|
|||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
// output:
|
/*
|
||||||
// {
|
output:
|
||||||
// // optimized SVG data string
|
|
||||||
// data: '<svg width="10" height="20">test</svg>'
|
{
|
||||||
// // additional info such as width/height and start/end bytes length
|
// optimized SVG data string
|
||||||
// info: {
|
data: '<svg width="10" height="20">test</svg>'
|
||||||
// width: '10',
|
// additional info such as width/height and start/end bytes length
|
||||||
// height: '20',
|
info: {
|
||||||
// inBytes: 52,
|
width: '10',
|
||||||
// outBytes: 38
|
height: '20',
|
||||||
// }
|
inBytes: 52,
|
||||||
// }
|
outBytes: 38,
|
||||||
|
time: N
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
})
|
})
|
||||||
// end promises chain
|
// end promises chain
|
||||||
|
@ -48,6 +48,8 @@ module.exports = INHERIT(/** @lends SVGO.prototype */{
|
|||||||
*/
|
*/
|
||||||
fromString: function(str) {
|
fromString: function(str) {
|
||||||
|
|
||||||
|
var startTime = Date.now();
|
||||||
|
|
||||||
str = decodeSVGDatauri(str);
|
str = decodeSVGDatauri(str);
|
||||||
|
|
||||||
return this.config
|
return this.config
|
||||||
@ -61,6 +63,8 @@ module.exports = INHERIT(/** @lends SVGO.prototype */{
|
|||||||
result.info.inBytes = Buffer.byteLength(str, 'utf-8');
|
result.info.inBytes = Buffer.byteLength(str, 'utf-8');
|
||||||
result.info.outBytes = Buffer.byteLength(result.data, 'utf-8');
|
result.info.outBytes = Buffer.byteLength(result.data, 'utf-8');
|
||||||
|
|
||||||
|
result.info.time = Date.now() - startTime;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user