测试使用 model 创建和直接纯函数调用性能差异 (v3)

Revision 3 of this benchmark created on


Setup

function getDataFromTable() {
	return {
  "id": "7155463609397313564",
  "type": 2,
  "name": "不能暴露隐私信息哈哈哈哈",
  "lastMessageId": "7234062447609479170",
  "lastMessagePosition": 374,
  "newMessageCount": 0,
  "updateTime": "1684311416",
  "avatarKey": "v2_3a4ce1ce-37c1-48aa-8ff4-28d13feda94g",
  "chatterId": "",
  "createTime": "1666011197",
  "description": "不能暴露隐私信息哈哈哈哈",
  "avatar": {
    "key": "v2_3a4ce1ce-37c1-48aa-8ff4-28d13feda94g",
    "urls": [
      "http://p1.pstatp.com/origin/v2_3a4ce1ce-37c1-48aa-8ff4-28d13feda94g"
    ],
    "width": 0,
    "height": 0,
    "type": 1,
    "exifOrientation": 0,
    "crypto": "",
    "fsUnit": ""
  },
  "ownerId": "6442600062672437517",
  "chatterCount": 915,
  "userCount": 915,
  "isDepartment": false,
  "isPublic": false,
  "isArchived": false,
  "isDeleted": false,
  "isRemind": true,
  "namePinyin": "[weiyi]feishuappfabuxinxitongbuqun",
  "role": 1,
  "isCustomerService": false,
  "textDraftId": "",
  "postDraftId": "",
  "noBadgedNewMessageCount": 0,
  "isShortcut": false,
  "announcement": {
    "content": "不能暴露隐私信息哈哈哈哈不能暴露隐私信息哈哈哈哈不能暴露隐私信息哈哈哈哈不能暴露隐私信息哈哈哈哈不能暴露隐私信息哈哈哈哈不能暴露隐私信息哈哈哈哈",
    "updateTime": "1666011914",
    "lastEditorId": "7074761271136043036",
    "docUrl": "不能暴露隐私信息哈哈哈哈",
    "enableOpenDoc": true,
    "useOpendoc": true
  },
  "offEditGroupChatInfo": false,
  "tenantId": "1",
  "isCustomIcon": true,
  "isDissolved": false,
  "messagePosition": 1,
  "feedType": 1,
  "lastVisibleMessageId": "7234062447609479170",
  "burnLife": 0,
  "isCrypto": false,
  "isMeeting": false,
  "isCrossTenant": false,
  "isSupportView": true,
  "firstMessagePosition": -1,
  "oncallId": "",
  "lastVisibleMessagePosition": 374,
  "readPosition": 0,
  "readPositionBadgeCount": 0,
  "lastMessagePositionBadgeCount": 185,
  "isPublicV2": true,
  "allowPost": true,
  "postType": 1,
  "chatMode": 3,
  "lastThreadId": "7234062447609479170",
  "lastThreadPosition": 307,
  "newThreadCount": 0,
  "noBadgedNewThreadCount": 0,
  "lastThreadPositionBadgeCount": 113,
  "readThreadPosition": 306,
  "readThreadPositionBadgeCount": 112,
  "lastVisibleThreadPosition": 307,
  "lastVisibleThreadId": "7234062447609479170",
  "showNickname": false,
  "lastDraftId": "",
  "lastReadPosition": -1,
  "lastReadOffset": 0,
  "isEdu": false,
  "isAdmin": false,
  "isMuteAtAll": false,
  "isDelayed": false,
  "addMemberPermission": 1,
  "atAllPermission": 1,
  "joinMessageVisible": 3,
  "quitMessageVisible": 3,
  "shareCardPermission": 1,
  "addMemberApply": 1,
  "messageVisibilitySetting": 1,
  "createUrgentSetting": 1,
  "createVideoConferenceSetting": 1,
  "pinPermissionSetting": 1,
  "topNoticePermissionSetting": 1,
  "chatTabPermissionSetting": 1,
  "chatDisplayModeSetting": 1,
  "putChatterApplyCount": 0,
  "showBanner": false,
  "miniAvatarKey": "",
  "sidebarId": "",
  "sidebarButtons": [],
  "myThreadsReadTimestamp": "0",
  "myThreadsLastTimestamp": "0",
  "myThreadsUnreadCount": 0,
  "myThreadsLastDisplayMessageId": "",
  "anonymousSetting": 1,
  "anonymousTotalQuota": "0",
  "isCrossWithKa": false,
  "anonymousId": "",
  "isTeam": false,
  "teamId": "0",
  "teamName": "",
  "teamChatType": 0,
  "chatterExtraStates": {},
  "joinedTeamInfos": [],
  "joinedTeams": {},
  "boundTeamInfos": [],
  "editMessageDraftId": "",
  "chatable": true,
  "muteable": true,
  "isSuper": false,
  "isPrivateMode": false,
  "isTenant": false,
  "isInBox": false,
  "boxId": "",
  "isAutoTranslate": false,
  "isAutoTypingTranslate": false,
  "typingTranslateSetting": {
    "isOpen": false,
    "targetLanguage": ""
  },
  "feedTag": [],
  "isFlag": false,
  "hasWaterMark": true,
  "avatarPath": "",
  "avatarUrls": [],
  "firstChatMessagePosition": -1,
  "tagInfo": {
    "tagDataItems": []
  },
  "isOfficialOncall": false,
  "isOfflineOncall": false,
  "restrictedModeSetting": {
    "switch": false,
    "copy": 1,
    "forward": 1,
    "download": 1,
    "screenshot": 1,
    "onTimeDelMsgSetting": {
      "status": false,
      "aliveTime": "0"
    }
  },
  "defDisplaySetting": 1,
  "scheduleMessageDraftId": "",
  "hasVcChatPermission": false,
  "adminPostSetting": 1,
  "canBeSortedAlphabetically": false,
  "tags": [
    10
  ],
  "themeId": "0",
  "isFrozen": false
}}

window.getDataFromTable = getDataFromTable;

class Model {
	constructor(data) {
		Object.assign(this, data)
	}
	toEntity() {
		return Object.assign({}, this)
	}
}

window.Model = Model;

window.trans2Cli = (data) => {
	return Object.assign({}, data)
}

Test runner

Ready to run.

Testing in
TestOps/sec
直接纯函数调用
const data = getDataFromTable();
const cliData =trans2Cli(data);
ready
case2
const data = getDataFromTable();
const modelData = new Model(data)
const cliData = modelData.toEntity();



ready

Revisions

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