From b2128609ac8159a14224deba399144b3400c8c20 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 13 Nov 2016 08:16:12 +0100 Subject: Finally give in and use React, minor tweeks. Preact (a minimalistic React alternative) had too many bugs ... --- thirdparty/preact/test/browser/performance.js | 245 -------------------------- 1 file changed, 245 deletions(-) delete mode 100644 thirdparty/preact/test/browser/performance.js (limited to 'thirdparty/preact/test/browser/performance.js') diff --git a/thirdparty/preact/test/browser/performance.js b/thirdparty/preact/test/browser/performance.js deleted file mode 100644 index e1f7d7956..000000000 --- a/thirdparty/preact/test/browser/performance.js +++ /dev/null @@ -1,245 +0,0 @@ -/*global coverage, ENABLE_PERFORMANCE, NODE_ENV*/ -/*eslint no-console:0*/ -/** @jsx h */ - -let { h, Component, render } = require(NODE_ENV==='production' ? '../../dist/preact.min.js' : '../../src/preact'); - -const MULTIPLIER = ENABLE_PERFORMANCE ? (coverage ? 5 : 1) : 999999; - - -let now = typeof performance!=='undefined' && performance.now ? () => performance.now() : () => +new Date(); - -function loop(iter, time) { - let start = now(), - count = 0; - while ( now()-start < time ) { - count++; - iter(); - } - return count; -} - - -function benchmark(iter, callback) { - let a = 0; - function noop() { - try { a++; } finally { a += Math.random(); } - } - - // warm - for (let i=3; i--; ) noop(), iter(); - - let count = 5, - time = 200, - passes = 0, - noops = loop(noop, time), - iterations = 0; - - function next() { - iterations += loop(iter, time); - setTimeout(++passes===count ? done : next, 10); - } - - function done() { - let ticks = Math.round(noops / iterations * count), - hz = iterations / count / time * 1000, - message = `${hz|0}/s (${ticks} ticks)`; - callback({ iterations, noops, count, time, ticks, hz, message }); - } - - next(); -} - - -describe('performance', function() { - let scratch; - - this.timeout(10000); - - before( () => { - if (coverage) { - console.warn('WARNING: Code coverage is enabled, which dramatically reduces performance. Do not pay attention to these numbers.'); - } - scratch = document.createElement('div'); - (document.body || document.documentElement).appendChild(scratch); - }); - - beforeEach( () => { - scratch.innerHTML = ''; - }); - - after( () => { - scratch.parentNode.removeChild(scratch); - scratch = null; - }); - - it('should rerender without changes fast', done => { - let jsx = ( -
-
-

a {'b'} c {0} d

- -
-
-
{}}> - - -
- - -
- - - - - - -
-
-
- ); - - let root; - benchmark( () => { - root = render(jsx, scratch, root); - }, ({ ticks, message }) => { - console.log(`PERF: empty diff: ${message}`); - expect(ticks).to.be.below(350 * MULTIPLIER); - done(); - }); - }); - - it('should rerender repeated trees fast', done => { - class Header extends Component { - render() { - return ( -
-

a {'b'} c {0} d

- -
- ); - } - } - class Form extends Component { - render() { - return ( -
{}}> - - -
- - -
- - - ); - } - } - class ButtonBar extends Component { - render() { - return ( - - - - - - - ); - } - } - class Button extends Component { - render(props) { - return - - - - - - - - ); - }, ({ ticks, message }) => { - console.log(`PERF: large VTree: ${message}`); - expect(ticks).to.be.below(2000 * MULTIPLIER); - done(); - }); - }); -}); -- cgit v1.2.3