Run details:
Mozilla/5.0 (Linux; Android 7.0; LG-M400) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36
Chrome Mobile 87
Android 7.0
Mobile
3 years ago
Test name Executions per second
Object spread 425476.4 Ops/sec
Patchinko 28401.5 Ops/sec
Ramda Lens 81507.7 Ops/sec
HTML Preparation code:
x
 
1
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
2
<script src=//unpkg.com/patchinko@4.1.0/immutable.js></script>
3
Script Preparation code:
 
// Initial state
var state = {
  visible: false,
  lazy: { test: true, number: 44 },
  count: 1
}
// Define reducers ahead of time
var spread = state => ({
  ...state,
  lazy: {
    ...state.lazy,
    test: !state.lazy.test
  }
})
var patchinko = state =>
  O(state, {
    lazy: O({
      test: O(test => !test),
    }),
  })
var lens = R.lensPath(["lazy", "test"])
var ramda = state => {
  return R.over(lens, test => !test, state)
}
Tests:
  • Object spread

     
    var data = spread(state)
  • Patchinko

     
    var data = patchinko(state)
  • Ramda Lens

     
    var data = ramda(state)