mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-08-15 18:45:06 +00:00
Add unregistered styles benchmark
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
const createDeepTree = ({ StyleSheet, View }) => {
|
||||
const createDeepTree = ({ StyleSheet, View }, options = {}) => {
|
||||
class DeepTree extends Component {
|
||||
static propTypes = {
|
||||
breadth: PropTypes.number.isRequired,
|
||||
@@ -11,6 +11,7 @@ const createDeepTree = ({ StyleSheet, View }) => {
|
||||
|
||||
render() {
|
||||
const { breadth, depth, id, wrap } = this.props;
|
||||
|
||||
let result = (
|
||||
<View
|
||||
style={[
|
||||
@@ -45,7 +46,7 @@ const createDeepTree = ({ StyleSheet, View }) => {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
const stylesObject = {
|
||||
outer: {
|
||||
padding: 4
|
||||
},
|
||||
@@ -77,7 +78,9 @@ const createDeepTree = ({ StyleSheet, View }) => {
|
||||
terminal2: {
|
||||
backgroundColor: 'red'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const styles = options.registerStyles ? StyleSheet.create(stylesObject) : stylesObject;
|
||||
|
||||
return DeepTree;
|
||||
};
|
||||
|
||||
@@ -4,16 +4,16 @@ import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ReactNative from 'react-native';
|
||||
|
||||
// React Native for Web implementation of the tree
|
||||
const DeepTree = createDeepTree(ReactNative);
|
||||
const deepTreeBenchmark = ({ breadth, depth, registerStyles = true, runs, wrap }, node) => () => {
|
||||
// React Native for Web implementation of the tree
|
||||
const DeepTree = createDeepTree(ReactNative, { registerStyles });
|
||||
|
||||
const deepTreeBenchmark = ({ breadth, depth, wrap, runs }, node) => () => {
|
||||
const setup = () => { };
|
||||
const setup = () => {};
|
||||
const teardown = () => ReactDOM.unmountComponentAtNode(node);
|
||||
|
||||
return benchmark({
|
||||
name: 'DeepTree',
|
||||
description: `depth=${depth}, breadth=${breadth}, wrap=${wrap})`,
|
||||
name: `DeepTree (${registerStyles ? 'registered' : 'unregistered'}) styles)`,
|
||||
description: `depth=${depth}, breadth=${breadth}, wrap=${wrap}`,
|
||||
runs,
|
||||
setup,
|
||||
teardown,
|
||||
|
||||
Reference in New Issue
Block a user