Vue Benchmark

by Guillaume Chau

HTML

<script src="https://unpkg.com/vue@2.2.1/dist/vue.min.js"></script>

<app-aur id="aur"></app-aur>
<app-inf id="inf"></app-inf>
<app-ng1 id="ng1"></app-ng1>
<app-ng2 id="ng2"></app-ng2>
<app-ng4 id="ng4"></app-ng4>
<app-vue id="vue"></app-vue>

JavaScript

console.clear()

var BENCHMARK_LIST_LENGTH = 10000;
var BENCHMARK_LIST = [];
var BENCHMARK_TIMER = window.performance.now();

for (let i = 0; i < BENCHMARK_LIST_LENGTH; i += 1) {
  BENCHMARK_LIST[i] = i;
}

var FRAMEWORK_NAME = 'Vue';
var FRAMEWORK_VERSION = Vue.version;

console.log(FRAMEWORK_VERSION);

Vue.component('app-vue', {
  data: () => {
    console.info(Math.round(window.performance.now() - BENCHMARK_TIMER) + ' ms'); // eslint-disable-line no-console
    return {
      items: BENCHMARK_LIST,
      show: false,
    }
  },
  template: `<div>
  	<version v-for="item in items" :key="item"></version>
	</div>`,
  created () {
  	this._timer = window.performance.now()
  },
  mounted () {
  	console.log(Math.round(window.performance.now() - this._timer) + ' ms')
  },
});

Vue.component('version', {
	functional: true,
	render (h, context) {
  	return h('div', {
    	class: 'row',
      style: 'float: left; width: 100%',
      on: {
      	click (event) {
        	console.info(event)
        },
      },
    }, [
    	h('div', {
      	class: 'small-12 column',
      }, [
      	h('hr', {	style: 'margin-bottom: 5px;' }),
        h('small', { style: 'float: right;' }, `${FRAMEWORK_NAME} ${FRAMEWORK_VERSION}`)
      ])
    ])
  }
});

new Vue({
  el: '#vue'
})