Spread 和 Object.assign() 对比

JavaScript performance comparison

Test case created by zhangxiangliang

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Spread
let user = {
    allowNotification: true,
    avatarHd: "",
    blacklist: false,
    blogAddress: "github.com/pushmetop",
    collectedEntriesCount: 17,
    collectionSetCount: 0,
    community: {
        github: {
            company: "pushmetop",
            username: "zhangxiangliang",
        }
    },
    company: "pushmetop",
    deviceType: "android",
    editorType: "markdown",
    email: "",
    emailVerified: false,
    followeesCount: 9,
    followersCount: 682,
    isAuthor: false,
    isUnitedAuthor: false,
    jobTitle: "全栈魔法师",
    likedPinCount: 7,
    pinCount: 1,
    postedEntriesCount: 0,
    postedPostsCount: 30,
    role: "guest",
    selfDescription: "假如我年少有为",
    subscribedTagsCount: 1,
    topicCommentCount: 61,
    totalCollectionsCount: 720,
    totalCommentsCount: 95,
    totalHotIndex: 0,
    totalViewsCount: 30526,
    useLeancloudPwd: false,
    username: "zhangxiangliang",
    viewedEntriesCount: 754,
}

user = { age: 18, ...user };
pending…
Object.assign()
let user = {
    allowNotification: true,
    avatarHd: "",
    blacklist: false,
    blogAddress: "github.com/pushmetop",
    collectedEntriesCount: 17,
    collectionSetCount: 0,
    community: {
        github: {
            company: "pushmetop",
            username: "zhangxiangliang",
        }
    },
    company: "pushmetop",
    deviceType: "android",
    editorType: "markdown",
    email: "",
    emailVerified: false,
    followeesCount: 9,
    followersCount: 682,
    isAuthor: false,
    isUnitedAuthor: false,
    jobTitle: "全栈魔法师",
    likedPinCount: 7,
    pinCount: 1,
    postedEntriesCount: 0,
    postedPostsCount: 30,
    role: "guest",
    selfDescription: "假如我年少有为",
    subscribedTagsCount: 1,
    topicCommentCount: 61,
    totalCollectionsCount: 720,
    totalCommentsCount: 95,
    totalHotIndex: 0,
    totalViewsCount: 30526,
    useLeancloudPwd: false,
    username: "zhangxiangliang",
    viewedEntriesCount: 754,
}

user = Object.assign({},{ age: 18}, user);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments