HTML Preparation code:
x
 
1
<script src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
2
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
3
<script src="http://fb.me/JSXTransformer-0.12.2.js"></script>
4
5
<div id="root"></div>
6
7
<script type="text/jsx">  
8
class AppComp extends React.Component {
9
  constructor() {
10
    super();
11
    this.state = {
12
      count : 0,
13
      type : 'fn'
14
    }
15
  }
16
  render() {
17
    return (
18
      <div>
19
        {this.state.type === 'fn' ?
20
          <DisplayAsFn  value={this.state.count} />
21
        :
22
          <DisplayAsVar value={this.state.count} />
23
        }
24
      </div>
25
    );
26
  }
27
}
28
function DisplayAsFn({value}) {
29
  const renderValue = () => {
30
    return <span>{value}</span>
31
  };
32
  return <div>Fn : {renderValue()}</div>
33
}
34
function DisplayAsVar({value}) {
35
  const renderValue = <span>{value}</span>
36
  return <div>Var : {renderValue}</div>
37
}
38
var appComp = ReactDOM.render(
39
  <AppComp />,
40
  document.querySelector('#root')
41
);
42
function add1() {
43
  appComp.setState({count: appComp.state.count + 1});
44
}
45
function setType(type) {
46
  appComp.setState({type});
47
}
48
</script>
49
Tests:
  • Render with Fn

     
    appComp.setState({
      count: appComp.state.count + 1,
      type : 'fn'
    });
  • Render with Var

     
    appComp.setState({
      count: appComp.state.count + 1,
      type : 'var'
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Render with Fn
    Render with Var

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Chrome 117 on Windows
View result in a separate tab
Test name Executions per second
Render with Fn 339941.1 Ops/sec
Render with Var 342274.9 Ops/sec