我打电话给:
Y.DataSchema.JSON.apply( { ... }, "..." )
针对一个大型复杂 JSON 字符串——大小为 275K,元素嵌套四层。此外,模式中的一些解析器也调用 Y.DataSchema.JSON.apply()。
在 Chrome 和 IE8 中,这个调用需要不到 0.5 秒。 在FF中,大约4秒!
任何想法为什么会有如此巨大的性能差异,以及我能做些什么?更多细节如下。
谢谢,直流
细节:
- YUI 3.7.3 版
- 我刚刚尝试了最新版本 3.10.3——没有重大变化。
- FF 版本 21,带有 FireBug 1.11.4
- 在下面的调用中,
rtnData
大约有 275K 长,并且完全符合架构。在这里包含它是不切实际的。 完整的调用是:
thisBlock._data = Y.DataSchema.JSON.apply( { resultListLocator: 'attendanceResults.clients.items', resultFields: [ { key: "activityOccurrenceLocationId", locator: 'attendanceDetails._attributes.activityOccurrenceLocationId' }, { key: "startDate", locator: 'attendanceDetails._attributes.startDate', parser: DT.jsonParser.date }, { key: "endDate", locator: 'attendanceDetails._attributes.endDate', parser: DT.jsonParser.date }, { key: "isisClientId", locator: "_attributes.isisClientId" }, { key: "personId", locator: "_attributes.personId" }, { key: "salutation", locator: "salutation" }, { key: "firstName", locator: "firstName" }, { key: "lastName", locator: "lastName" }, { key: "teamId", locator: "team._attributes.attendanceTeamId", parser: DT.jsonParser.integer }, { key: "teamName", locator: "team.attendanceTeamName" }, { key: "transportation", locator: "plannedTransportation.items" }, { key: "attendance", locator: "attendanceDetails.items", parser: function( attendance ) { return Y.DataSchema.JSON.apply( { resultFields: [ { key: "actualAttendanceId", locator: '_attributes.actualAttendanceId' }, { key: "attendanceDate", locator: 'attendanceDate', parser: DT.jsonParser.date }, { key: "timeslotCode", locator: 'timeslotCode' }, { key: "timeslotName", locator: 'timeslotCode', parser: function( timeslotCode ) { var timeslotName; Y.some( thisBlock._timeslots, function( timeslot ) { if( timeslot.timeslotCode == timeslotCode ) { timeslotName = timeslot.timeslotName; return true; } }); return timeslotName; } }, { key: "plannedAttendanceValueCode", locator: 'scheduled.attendanceValueCode' }, { key: "plannedAttendanceValueName", locator: 'scheduled.attendanceValueCode', parser: function( attendanceValueCode ) { var attendanceValueName; Y.some( thisBlock._attendanceValues, function( attendanceValue ) { if( attendanceValue.attendanceValueCode == attendanceValueCode ) { attendanceValueName = attendanceValue.attendanceValueName; return true; } }); return attendanceValueName; } }, { key: "plannedAttendanceValueType", locator: 'scheduled.attendanceValueCode', parser: function( attendanceValueCode ) { var attendanceValueType; Y.some( thisBlock._attendanceValues, function( attendanceValue ) { if( attendanceValue.attendanceValueCode == attendanceValueCode ) { attendanceValueType = attendanceValue.attendanceValueType; return true; } }); return attendanceValueType; } }, { key: "plannedAttendanceValueIsCustom", locator: 'scheduled.attendanceValueCode', parser: function( attendanceValueCode ) { var isCustom; Y.some( thisBlock._attendanceValues, function( attendanceValue ) { if( attendanceValue.attendanceValueCode == attendanceValueCode ) { isCustom = attendanceValue.isCustom; return true; } }); return isCustom; } }, { key: "attendanceValueCode", locator: 'actual.attendanceValueCode' }, { key: "attendanceValueIsException", locator: 'actual.isException', parser: DT.jsonParser.bool }, { key: "attendanceValueName", locator: 'actual.attendanceValueCode', parser: function( attendanceValueCode ) { var attendanceValueName; Y.some( thisBlock._attendanceValues, function( attendanceValue ) { if( attendanceValue.attendanceValueCode == attendanceValueCode ) { attendanceValueName = attendanceValue.attendanceValueName; return true; } }); return attendanceValueName; } }, { key: "attendanceValueType", locator: 'actual.attendanceValueCode', parser: function( attendanceValueCode ) { var attendanceValueType; Y.some( thisBlock._attendanceValues, function( attendanceValue ) { if( attendanceValue.attendanceValueCode == attendanceValueCode ) { attendanceValueType = attendanceValue.attendanceValueType; return true; } }); return attendanceValueType; } }, { key: "attendanceValueIsCustom", locator: 'actual.attendanceValueCode', parser: function( attendanceValueCode ) { var isCustom; Y.some( thisBlock._attendanceValues, function( attendanceValue ) { if( attendanceValue.attendanceValueCode == attendanceValueCode ) { isCustom = attendanceValue.isCustom; return true; } }); return isCustom; } } ] }, attendance ).results; } } ] }, rtnData ).results;