Y.DataSchema.JSON.apply()FireFox中的性能问题

时间:2013-06-12 18:53:28

标签: performance firefox yui

我在打电话:

Y.DataSchema.JSON.apply( { ... }, "..." )

针对一个大型复杂的JSON字符串 - 大小为275K,其中元素嵌套了四层深度。此外,模式中的一些解析器还调用Y.DataSchema.JSON.apply()。

在Chrome和IE8中,此通话时间不到0.5秒。 在FF中,大约4秒!

为什么会出现如此剧烈的性能差异以及我能做些什么呢?更多细节如下。

谢谢, DC


详细说明:

  • 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;
    

1 个答案:

答案 0 :(得分:2)

原来这是一个Firefox / Firebug问题:

Bug 876075 - Firefox 21 slows down JSD and page load performance

来自问题:

  

自从Firefox 21发布以来,有很多关于Firebug降低页面加载的投诉。根据报告,在启用控制台或“脚本”面板时会发生这种情况。

     

这很可能与JSD有关,因为Console和Scrip面板都会激活它。

碰巧它影响了我正在处理的这个特定页面,而不影响其他页面。

我禁用了Firebug,一切恢复正常!