Skip to content

v8.serialize is so strange! #1059

@askforone

Description

@askforone
  • **Node.js Version 8.94:
  • OS: Win7 64

I think v8.serialize will be faster than JSON... but not?
and
v8.serialize(value) is slower than v8.serialize(value).toString()

Plz test the codes below;

// I am an example of JS code
var deco_getSyncRunTime = function(func, times){
    var t = Date.now();
    for(var i=0; i<times; i++){
        func();
    }
    console.log('run time:', Date.now() - t);
    console.log(process.memoryUsage());
}

var v8 = require('v8');
var test_func_1 = function(){
    return v8.serialize(obj).toString(); //1e6   11sec
}
var test_func_2 = function(){
    return v8.serialize(obj);  //1e6   21sec    why
}
var obj = {"dirty_map":{"pid":1},"pid":1,"uid":"","wid":"","phone":"","wechat":"","currency_1":3000,"char_1":{"dirty_map":{"money":1},"money":5}};

setTimeout(function(){
    deco_getSyncRunTime(test_func_1, 1e6);
    //deco_getSyncRunTime(test_func_2, 1e6);
}, 1e4);

-->

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions