1
0
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:
deepsweet
2012-12-14 05:56:24 +04:00
parent 0229a4029f
commit 74bbdb46cc
4 changed files with 52 additions and 36 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
});