【问题标题】:Y.DataSchema.JSON.apply() performance problems in FireFoxFireFox 中的 Y.DataSchema.JSON.apply() 性能问题
【发布时间】:2013-06-12 18:53:28
【问题描述】:

我在打电话:

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;
    

【问题讨论】:

    标签: performance firefox yui


    【解决方案1】:

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

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

    来自问题:

    自从 Firefox 21 发布以来,有很多关于 Firebug 减慢页面加载的抱怨。根据报告,它发生在控制台或脚本面板启用时。

    这(很有可能)与 JSD 有关,因为控制台和脚本面板都激活了它。

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

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

    【讨论】:

    • 好东西。我会将此答案标记为问题的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-21
    • 1970-01-01
    相关资源
    最近更新 更多