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) {
|
||||
|
||||
console.log(result);
|
||||
// output:
|
||||
// {
|
||||
// // optimized SVG data string
|
||||
// data: '<svg width="10" height="20">test</svg>'
|
||||
// // additional info such as width/height and start/end bytes length
|
||||
// info: {
|
||||
// width: '10',
|
||||
// height: '20',
|
||||
// inBytes: 59,
|
||||
// outBytes: 38
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
output:
|
||||
|
||||
{
|
||||
// optimized SVG data string
|
||||
data: '<svg width="10" height="20">test</svg>'
|
||||
// additional info such as width/height and start/end bytes length
|
||||
info: {
|
||||
width: '10',
|
||||
height: '20',
|
||||
inBytes: 59,
|
||||
outBytes: 38,
|
||||
time: N
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
})
|
||||
// end promises chain
|
||||
|
@ -15,18 +15,22 @@ svgo
|
||||
.then(function(result) {
|
||||
|
||||
console.log(result);
|
||||
// output:
|
||||
// {
|
||||
// // optimized SVG data string
|
||||
// data: '<svg width="10" height="20">test</svg>'
|
||||
// // additional info such as width/height and start/end bytes length
|
||||
// info: {
|
||||
// width: '10',
|
||||
// height: '20',
|
||||
// inBytes: 59,
|
||||
// outBytes: 38
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
output:
|
||||
|
||||
{
|
||||
// optimized SVG data string
|
||||
data: '<svg width="10" height="20">test</svg>'
|
||||
// additional info such as width/height and start/end bytes length
|
||||
info: {
|
||||
width: '10',
|
||||
height: '20',
|
||||
inBytes: 59,
|
||||
outBytes: 38,
|
||||
time: N
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
})
|
||||
// end promises chain
|
||||
|
@ -10,18 +10,22 @@ svgo
|
||||
.then(function(result) {
|
||||
|
||||
console.log(result);
|
||||
// output:
|
||||
// {
|
||||
// // optimized SVG data string
|
||||
// data: '<svg width="10" height="20">test</svg>'
|
||||
// // additional info such as width/height and start/end bytes length
|
||||
// info: {
|
||||
// width: '10',
|
||||
// height: '20',
|
||||
// inBytes: 52,
|
||||
// outBytes: 38
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
output:
|
||||
|
||||
{
|
||||
// optimized SVG data string
|
||||
data: '<svg width="10" height="20">test</svg>'
|
||||
// additional info such as width/height and start/end bytes length
|
||||
info: {
|
||||
width: '10',
|
||||
height: '20',
|
||||
inBytes: 52,
|
||||
outBytes: 38,
|
||||
time: N
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
})
|
||||
// end promises chain
|
||||
|
@ -48,6 +48,8 @@ module.exports = INHERIT(/** @lends SVGO.prototype */{
|
||||
*/
|
||||
fromString: function(str) {
|
||||
|
||||
var startTime = Date.now();
|
||||
|
||||
str = decodeSVGDatauri(str);
|
||||
|
||||
return this.config
|
||||
@ -61,6 +63,8 @@ module.exports = INHERIT(/** @lends SVGO.prototype */{
|
||||
result.info.inBytes = Buffer.byteLength(str, 'utf-8');
|
||||
result.info.outBytes = Buffer.byteLength(result.data, 'utf-8');
|
||||
|
||||
result.info.time = Date.now() - startTime;
|
||||
|
||||
return result;
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user