@samitouri / QOS-React-2 / commits / ba0792e72b

Add createClass stress test

Running this is left as an exercise for the reader, since my measure.py isn't designed for this at present. But something like this might work: ```diff diff --git a/scripts/bench/measure.py b/scripts/bench/measure.py index 4cedf47..627ec97 100755 --- a/scripts/bench/measure.py +++ b/scripts/bench/measure.py @@ -79,15 +79,12 @@ def _measure_ssr_ms(engine, react_path, bench_name, bench_path, measure_warm): if (typeof React !== 'object') throw new Error('React not laoded'); report('factory_ms', END - START); - globalEval(readFile(ENV.bench_path)); - if (typeof Benchmark !== 'function') { - throw new Error('benchmark not loaded'); - } + globalEval("bm = (function(){" + readFile("bench-createclass-madman.js") + "})"); + bm(); var START = now(); - var html = React.renderToString(React.createElement(Benchmark)); - html.charCodeAt(0); // flatten ropes + bm(); var END = now(); - report('ssr_' + ENV.bench_name + '_cold_ms', END - START); + report('cc_' + ENV.bench_name + '_cold_ms', END - START); var warmup = ENV.measure_warm ? 80 : 0; var trials = ENV.measure_warm ? 40 : 0; @@ -119,7 +116,7 @@ def _main(): return 1 react_path = sys.argv[1] - trials = 30 + trials = 60 sys.stderr.write("Measuring SSR for PE benchmark (%d trials)\n" % trials) for i in range(trials): for engine in [ @@ -132,7 +129,7 @@ def _main(): sys.stderr.flush() sys.stderr.write("\n") - trials = 3 + trials = 0#3 sys.stderr.write("Measuring SSR for PE with warm JIT (%d slow trials)\n" % trials) for i in range(trials): for engine in [ ```

Ben Alpert committed Nov 25, 2015 at 18:22 UTC ba0792e72bb87e448bbf86f96e2ce4045b250555
1 file changed +243
scripts/bench/bench-createclass.js new
+243
@@ -0,0 +1,243 @@
1 +React.createClass({
2 + displayName: "UnimplementedView",
3 + setNativeProps: function() {},
4 + render: function() {},
5 +});
6 +var mixin1 = {
7 + measure: function() {},
8 + measureLayout: function() {},
9 + setNativeProps: function() {},
10 + focus: function() {},
11 + blur: function() {},
12 + componentWillMount: function() {},
13 + componentWillReceiveProps: function() {},
14 +};
15 +React.createClass({
16 + displayName: "View",
17 + mixins: [mixin1],
18 + viewConfig: {uiViewClassName: "RCTView", validAttributes: null},
19 + statics: {AccessibilityTraits: null, AccessibilityComponentType: null},
20 + propTypes: {accessible: function() {}, accessibilityLabel: function() {}, accessibilityComponentType: function() {}, accessibilityLiveRegion: function() {}, importantForAccessibility: function() {}, accessibilityTraits: function() {}, onAccessibilityTap: function() {}, onMagicTap: function() {}, testID: function() {}, onResponderGrant: function() {}, onResponderMove: function() {}, onResponderReject: function() {}, onResponderRelease: function() {}, onResponderTerminate: function() {}, onResponderTerminationRequest: function() {}, onStartShouldSetResponder: function() {}, onStartShouldSetResponderCapture: function() {}, onMoveShouldSetResponder: function() {}, onMoveShouldSetResponderCapture: function() {}, onLayout: function() {}, pointerEvents: function() {}, style: function() {}, removeClippedSubviews: function() {}, renderToHardwareTextureAndroid: function() {}, shouldRasterizeIOS: function() {}, collapsable: function() {}, needsOffscreenAlphaCompositing: function() {}},
21 + render: function() {},
22 +});
23 +var mixin2 = {
24 + componentWillUnmount: function() {},
25 + setTimeout: function() {},
26 + clearTimeout: function() {},
27 + setInterval: function() {},
28 + clearInterval: function() {},
29 + setImmediate: function() {},
30 + clearImmediate: function() {},
31 + requestAnimationFrame: function() {},
32 + cancelAnimationFrame: function() {},
33 +};
34 +var mixin3 = {
35 + componentWillUnmount: function() {},
36 + _interactionMixinHandles: {},
37 + createInteractionHandle: function() {},
38 + clearInteractionHandle: function() {},
39 + runAfterInteractions: function() {},
40 +};
41 +var mixin4 = {
42 + componentWillMount: function() {},
43 + componentWillUnmount: function() {},
44 + addListenerOn: function() {},
45 +};
46 +React.createClass({
47 + displayName: "Navigator",
48 + propTypes: {configureScene: function() {}, renderScene: function() {}, initialRoute: function() {}, initialRouteStack: function() {}, onWillFocus: function() {}, onDidFocus: function() {}, navigationBar: function() {}, navigator: function() {}, sceneStyle: function() {}},
49 + statics: {BreadcrumbNavigationBar: null, NavigationBar: null, SceneConfigs: null},
50 + mixins: [mixin2, mixin3, mixin4],
51 + getDefaultProps: function() {},
52 + getInitialState: function() {},
53 + componentWillMount: function() {},
54 + componentDidMount: function() {},
55 + componentWillUnmount: function() {},
56 + immediatelyResetRouteStack: function() {},
57 + _transitionTo: function() {},
58 + _handleSpringUpdate: function() {},
59 + _completeTransition: function() {},
60 + _emitDidFocus: function() {},
61 + _emitWillFocus: function() {},
62 + _hideScenes: function() {},
63 + _disableScene: function() {},
64 + _enableScene: function() {},
65 + _onAnimationStart: function() {},
66 + _onAnimationEnd: function() {},
67 + _setRenderSceneToHardwareTextureAndroid: function() {},
68 + _handleTouchStart: function() {},
69 + _handleMoveShouldSetPanResponder: function() {},
70 + _doesGestureOverswipe: function() {},
71 + _deltaForGestureAction: function() {},
72 + _handlePanResponderRelease: function() {},
73 + _handlePanResponderTerminate: function() {},
74 + _attachGesture: function() {},
75 + _detachGesture: function() {},
76 + _handlePanResponderMove: function() {},
77 + _moveAttachedGesture: function() {},
78 + _matchGestureAction: function() {},
79 + _transitionSceneStyle: function() {},
80 + _transitionBetween: function() {},
81 + _handleResponderTerminationRequest: function() {},
82 + _getDestIndexWithinBounds: function() {},
83 + _jumpN: function() {},
84 + jumpTo: function() {},
85 + jumpForward: function() {},
86 + jumpBack: function() {},
87 + push: function() {},
88 + _popN: function() {},
89 + pop: function() {},
90 + replaceAtIndex: function() {},
91 + replace: function() {},
92 + replacePrevious: function() {},
93 + popToTop: function() {},
94 + popToRoute: function() {},
95 + replacePreviousAndPop: function() {},
96 + resetTo: function() {},
97 + getCurrentRoutes: function() {},
98 + _cleanScenesPastIndex: function() {},
99 + _renderScene: function() {},
100 + _renderNavigationBar: function() {},
101 + render: function() {},
102 + _getNavigationContext: function() {},
103 +});
104 +var mixin5 = {
105 + mixins: [mixin4],
106 + statics: {DecelerationRate: null},
107 + scrollResponderMixinGetInitialState: function() {},
108 + scrollResponderHandleScrollShouldSetResponder: function() {},
109 + scrollResponderHandleStartShouldSetResponder: function() {},
110 + scrollResponderHandleStartShouldSetResponderCapture: function() {},
111 + scrollResponderHandleResponderReject: function() {},
112 + scrollResponderHandleTerminationRequest: function() {},
113 + scrollResponderHandleTouchEnd: function() {},
114 + scrollResponderHandleResponderRelease: function() {},
115 + scrollResponderHandleScroll: function() {},
116 + scrollResponderHandleResponderGrant: function() {},
117 + scrollResponderHandleScrollBeginDrag: function() {},
118 + scrollResponderHandleScrollEndDrag: function() {},
119 + scrollResponderHandleMomentumScrollBegin: function() {},
120 + scrollResponderHandleMomentumScrollEnd: function() {},
121 + scrollResponderHandleTouchStart: function() {},
122 + scrollResponderHandleTouchMove: function() {},
123 + scrollResponderIsAnimating: function() {},
124 + scrollResponderScrollTo: function() {},
125 + scrollResponderScrollWithouthAnimationTo: function() {},
126 + scrollResponderZoomTo: function() {},
127 + scrollResponderScrollNativeHandleToKeyboard: function() {},
128 + scrollResponderInputMeasureAndScrollToKeyboard: function() {},
129 + scrollResponderTextInputFocusError: function() {},
130 + componentWillMount: function() {},
131 + scrollResponderKeyboardWillShow: function() {},
132 + scrollResponderKeyboardWillHide: function() {},
133 + scrollResponderKeyboardDidShow: function() {},
134 + scrollResponderKeyboardDidHide: function() {},
135 +};
136 +React.createClass({
137 + displayName: "ScrollView",
138 + propTypes: {accessible: function() {}, accessibilityLabel: function() {}, accessibilityComponentType: function() {}, accessibilityLiveRegion: function() {}, importantForAccessibility: function() {}, accessibilityTraits: function() {}, onAccessibilityTap: function() {}, onMagicTap: function() {}, testID: function() {}, onResponderGrant: function() {}, onResponderMove: function() {}, onResponderReject: function() {}, onResponderRelease: function() {}, onResponderTerminate: function() {}, onResponderTerminationRequest: function() {}, onStartShouldSetResponder: function() {}, onStartShouldSetResponderCapture: function() {}, onMoveShouldSetResponder: function() {}, onMoveShouldSetResponderCapture: function() {}, onLayout: function() {}, pointerEvents: function() {}, style: function() {}, removeClippedSubviews: function() {}, renderToHardwareTextureAndroid: function() {}, shouldRasterizeIOS: function() {}, collapsable: function() {}, needsOffscreenAlphaCompositing: function() {}, automaticallyAdjustContentInsets: function() {}, contentInset: function() {}, contentOffset: function() {}, bounces: function() {}, bouncesZoom: function() {}, alwaysBounceHorizontal: function() {}, alwaysBounceVertical: function() {}, centerContent: function() {}, contentContainerStyle: function() {}, decelerationRate: function() {}, horizontal: function() {}, directionalLockEnabled: function() {}, canCancelContentTouches: function() {}, keyboardDismissMode: function() {}, keyboardShouldPersistTaps: function() {}, maximumZoomScale: function() {}, minimumZoomScale: function() {}, onScroll: function() {}, onScrollAnimationEnd: function() {}, onContentSizeChange: function() {}, pagingEnabled: function() {}, scrollEnabled: function() {}, scrollEventThrottle: function() {}, scrollIndicatorInsets: function() {}, scrollsToTop: function() {}, showsHorizontalScrollIndicator: function() {}, showsVerticalScrollIndicator: function() {}, stickyHeaderIndices: function() {}, snapToInterval: function() {}, snapToAlignment: function() {}, zoomScale: function() {}, onRefreshStart: function() {}},
139 + mixins: [mixin5],
140 + getInitialState: function() {},
141 + setNativeProps: function() {},
142 + endRefreshing: function() {},
143 + getScrollResponder: function() {},
144 + getInnerViewNode: function() {},
145 + scrollTo: function() {},
146 + scrollWithoutAnimationTo: function() {},
147 + handleScroll: function() {},
148 + _handleContentOnLayout: function() {},
149 + render: function() {},
150 +});
151 +var mixin6 = {
152 + componentWillUnmount: function() {},
153 + setTimeout: function() {},
154 + clearTimeout: function() {},
155 + setInterval: function() {},
156 + clearInterval: function() {},
157 + setImmediate: function() {},
158 + clearImmediate: function() {},
159 + requestAnimationFrame: function() {},
160 + cancelAnimationFrame: function() {},
161 +};
162 +React.createClass({
163 + displayName: "AdsManagerTabsModalView",
164 + contextTypes: {navigation: function() {}},
165 + mixins: [mixin6, mixin4],
166 + getDefaultProps: function() {},
167 + getInitialState: function() {},
168 + componentWillMount: function() {},
169 + componentDidMount: function() {},
170 + componentWillUnmount: function() {},
171 + onTabSelect: function() {},
172 + _handleConnectivityChange: function() {},
173 + _onTabTap: function() {},
174 + startCreateFlow: function() {},
175 + render: function() {},
176 + _renderTabs: function() {},
177 + _onAdCreated: function() {},
178 + _onRemoteNotification: function() {},
179 + _setAccountFromURL: function() {},
180 + _updateBadgeCount: function() {},
181 + _onRetry: function() {},
182 + _getUnseenNotifsCount: function() {},
183 + _pushNotifPermalink: function() {},
184 + _onMobileConfigsLoadDone: function() {},
185 + _getAccountRoute: function() {},
186 + _getNotifsRoute: function() {},
187 + _getSettingsRoute: function() {},
188 + _getCampaignsRoute: function() {},
189 + _getNavStack: function() {},
190 + _onAccountChanged: function() {},
191 + _onHelpCenterRequested: function() {},
192 + _onGlobalError: function() {},
193 + _onGlobalErrorToastDidClose: function() {},
194 + _onShowNUX: function() {},
195 + _closeToastAndPopover: function() {},
196 + _onTabLayout: function() {},
197 + _onRootNavigationWillChange: function() {},
198 + _handleOpenURL: function() {},
199 + _updateAccountIDFromInLink: function() {},
200 + _pushInLink: function() {},
201 + _pushExternalRoute: function() {},
202 + _canPushExernalRoute: function() {},
203 + _hasAccountTab: function() {},
204 + _hasCampaignsTab: function() {},
205 + _getTabForURL: function() {},
206 + _getTabForExternalRoute: function() {},
207 +});
208 +React.createClass({
209 + displayName: "ActionBarButton",
210 + mixins: [mixin1, mixin6],
211 + propTypes: {label: function() {}, iconOnly: function() {}, imageSource: function() {}, style: function() {}, onContentMeasured: function() {}, onPress: function() {}},
212 + componentDidMount: function() {},
213 + render: function() {},
214 +});
215 +React.createClass({
216 + displayName: "ListView",
217 + mixins: [mixin5, mixin2],
218 + statics: {DataSource: null},
219 + propTypes: {accessible: function() {}, accessibilityLabel: function() {}, accessibilityComponentType: function() {}, accessibilityLiveRegion: function() {}, importantForAccessibility: function() {}, accessibilityTraits: function() {}, onAccessibilityTap: function() {}, onMagicTap: function() {}, testID: function() {}, onResponderGrant: function() {}, onResponderMove: function() {}, onResponderReject: function() {}, onResponderRelease: function() {}, onResponderTerminate: function() {}, onResponderTerminationRequest: function() {}, onStartShouldSetResponder: function() {}, onStartShouldSetResponderCapture: function() {}, onMoveShouldSetResponder: function() {}, onMoveShouldSetResponderCapture: function() {}, onLayout: function() {}, pointerEvents: function() {}, style: function() {}, removeClippedSubviews: function() {}, renderToHardwareTextureAndroid: function() {}, shouldRasterizeIOS: function() {}, collapsable: function() {}, needsOffscreenAlphaCompositing: function() {}, automaticallyAdjustContentInsets: function() {}, contentInset: function() {}, contentOffset: function() {}, bounces: function() {}, bouncesZoom: function() {}, alwaysBounceHorizontal: function() {}, alwaysBounceVertical: function() {}, centerContent: function() {}, contentContainerStyle: function() {}, decelerationRate: function() {}, horizontal: function() {}, directionalLockEnabled: function() {}, canCancelContentTouches: function() {}, keyboardDismissMode: function() {}, keyboardShouldPersistTaps: function() {}, maximumZoomScale: function() {}, minimumZoomScale: function() {}, onScroll: function() {}, onScrollAnimationEnd: function() {}, onContentSizeChange: function() {}, pagingEnabled: function() {}, scrollEnabled: function() {}, scrollEventThrottle: function() {}, scrollIndicatorInsets: function() {}, scrollsToTop: function() {}, showsHorizontalScrollIndicator: function() {}, showsVerticalScrollIndicator: function() {}, stickyHeaderIndices: function() {}, snapToInterval: function() {}, snapToAlignment: function() {}, zoomScale: function() {}, onRefreshStart: function() {}, dataSource: function() {}, renderSeparator: function() {}, renderRow: function() {}, initialListSize: function() {}, onEndReached: function() {}, onEndReachedThreshold: function() {}, pageSize: function() {}, renderFooter: function() {}, renderHeader: function() {}, renderSectionHeader: function() {}, renderScrollComponent: function() {}, scrollRenderAheadDistance: function() {}, onChangeVisibleRows: function() {}},
220 + getMetrics: function() {},
221 + getScrollResponder: function() {},
222 + setNativeProps: function() {},
223 + getDefaultProps: function() {},
224 + getInitialState: function() {},
225 + getInnerViewNode: function() {},
226 + componentWillMount: function() {},
227 + componentDidMount: function() {},
228 + componentWillReceiveProps: function() {},
229 + componentDidUpdate: function() {},
230 + onRowHighlighted: function() {},
231 + render: function() {},
232 + _measureAndUpdateScrollProps: function() {},
233 + _onContentSizeChange: function() {},
234 + _onLayout: function() {},
235 + _setScrollVisibleLength: function() {},
236 + _updateChildFrames: function() {},
237 + _maybeCallOnEndReached: function() {},
238 + _renderMoreRowsIfNeeded: function() {},
239 + _pageInNewRows: function() {},
240 + _getDistanceFromEnd: function() {},
241 + _updateVisibleRows: function() {},
242 + _onScroll: function() {},
243 +});