mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
* Initial commit for WIP benchmarking infrastructure * fixed lint issues and ran prettier * added <rootDir>/scripts/bench/ to ignore paths for Jest * tidied up code and fixed a few bugs in the runner.js * fixed eslint * improved the benchmark output from the runner * fixed typo * tided up print output in runner.js * throw error if chrome canary is not installed on mac * added better bench stats output (tables) * added benchmark diff to table results * adds bundle size comparisons to results * tidied up the results * fixed prettier output * attempt to trigger bech for circleci build * fixes flow exlclusion for lighthouse module * added class components benchmark * cleaned up stats.js * stability changes * circleci node version to 7 * added another benchmark * added colours to the different benchmarks to check if being cached * force no-cache headers * added more info messages * refactor chrome launching. * fixed an issue where launcher.kill might fail * Move server to runner. Launch it only once. * tidy up * changes the logic in how the remote repo is checked out * removes bench from circleci build * removed colors from benchmarks (no longer needed) * added CI integration comment * added hacker news benchmark * added skipBuild functionality * relabelled remote * Add confidence intervals * added first meaningful paint * removed some unused code * reverted code.json * updated benchmark runs back to 10 * no longer breaks when results contain missing bundles * adds CPU throttling * renamed build to remote-repo * small fix to build * fixed bad merge * upped runs to 10 from 2 again * properly pulls master * removes old-bench * runs benchmarks in headless mode * adds a --headless option * improved the git build process * added README * updated based feedback from review * adds merge base commit sha * addressing more PR feedback * remove built JS react files * updated .gitignore * added combined bundle load times to the metrics
229 lines
4.8 KiB
JavaScript
229 lines
4.8 KiB
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
const e = React.createElement;
|
|
|
|
function timeAge(time) {
|
|
const now = new Date().getTime() / 1000;
|
|
const minutes = (now - time) / 60;
|
|
|
|
if (minutes < 60) {
|
|
return Math.round(minutes) + ' minutes ago';
|
|
}
|
|
return Math.round(minutes / 60) + ' hours ago';
|
|
}
|
|
|
|
function getHostUrl(url) {
|
|
return (url + '')
|
|
.replace('https://', '')
|
|
.replace('http://', '')
|
|
.split('/')[0]
|
|
}
|
|
|
|
function HeaderBar() {
|
|
return e('tr', {
|
|
style: {
|
|
backgroundColor: '#222',
|
|
},
|
|
}, e('table', {
|
|
style: {
|
|
padding: 4,
|
|
},
|
|
width: '100%',
|
|
cellSpacing: 0,
|
|
cellPadding: 0,
|
|
}, e('tbody', null,
|
|
e('tr', null,
|
|
e('td', {
|
|
style: {
|
|
width: 18,
|
|
paddingRight: 4,
|
|
},
|
|
},
|
|
e('a', {
|
|
href: '#',
|
|
},
|
|
e('img', {
|
|
src: 'logo.png',
|
|
width: 16,
|
|
height: 16,
|
|
style: {
|
|
border: '1px solid #00d8ff',
|
|
},
|
|
})
|
|
)
|
|
),
|
|
e('td', {
|
|
style: {
|
|
lineHeight: '12pt',
|
|
},
|
|
height: 10,
|
|
},
|
|
e('span', {
|
|
className: 'pagetop',
|
|
},
|
|
e('b', { className: 'hnname' }, 'React HN Benchmark'),
|
|
e('a', { href: '#' }, 'new'),
|
|
' | ',
|
|
e('a', { href: '#' }, 'comments'),
|
|
' | ',
|
|
e('a', { href: '#' }, 'show'),
|
|
' | ',
|
|
e('a', { href: '#' }, 'ask'),
|
|
' | ',
|
|
e('a', { href: '#' }, 'jobs'),
|
|
' | ',
|
|
e('a', { href: '#' }, 'submit')
|
|
)
|
|
)
|
|
)
|
|
)
|
|
));
|
|
}
|
|
|
|
function Story({ story, rank }) {
|
|
return [
|
|
e('tr', {
|
|
className: 'athing',
|
|
},
|
|
e('td', {
|
|
style: {
|
|
verticalAlign: 'top',
|
|
textAlign: 'right',
|
|
},
|
|
className: 'title',
|
|
},
|
|
e('span', {
|
|
className: 'rank',
|
|
}, `${rank}.`)
|
|
),
|
|
e('td', {
|
|
className: 'votelinks',
|
|
style: {
|
|
verticalAlign: 'top',
|
|
},
|
|
},
|
|
e('center', null,
|
|
e('a', {
|
|
href: '#',
|
|
},
|
|
e('div', {
|
|
className: 'votearrow',
|
|
title: 'upvote',
|
|
})
|
|
)
|
|
)
|
|
),
|
|
e('td', {
|
|
className: 'title',
|
|
},
|
|
e('a', {
|
|
href: '#',
|
|
className: 'storylink',
|
|
},
|
|
story.title
|
|
),
|
|
story.url ? (
|
|
e('span', {
|
|
className: 'sitebit comhead',
|
|
},
|
|
' (',
|
|
e('a', {
|
|
href: '#',
|
|
},
|
|
getHostUrl(story.url)
|
|
),
|
|
')'
|
|
)
|
|
) : null
|
|
)
|
|
),
|
|
e('tr', null,
|
|
e('td', {
|
|
colSpan: 2,
|
|
}),
|
|
e('td', {
|
|
className: 'subtext',
|
|
},
|
|
e('span', {
|
|
className: 'score',
|
|
}, `${story.score} points`),
|
|
' by ',
|
|
e('a', {
|
|
href: '#',
|
|
className: 'hnuser',
|
|
}, story.by),
|
|
' ',
|
|
e('span', {
|
|
className: 'age',
|
|
},
|
|
e('a', {
|
|
href: '#',
|
|
}, timeAge(story.time))
|
|
),
|
|
' | ',
|
|
e('a', {
|
|
href: '#',
|
|
}, 'hide'),
|
|
' | ',
|
|
e('a', {
|
|
href: '#',
|
|
}, `${ story.descendants || 0 } comments`)
|
|
)
|
|
),
|
|
e('tr', {
|
|
style: {
|
|
height: 5,
|
|
},
|
|
className: 'spacer',
|
|
})
|
|
];
|
|
}
|
|
|
|
function StoryList({ stories }) {
|
|
return e('tr', null,
|
|
e('td', null,
|
|
e('table', {
|
|
cellPadding: 0,
|
|
cellSpacing: 0,
|
|
classList: 'itemlist',
|
|
},
|
|
e('tbody', null,
|
|
stories.map((story, i) =>
|
|
e(Story, { story, rank: ++i, key: story.id })
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
function App({ stories }) {
|
|
return e('center', null,
|
|
e('table', {
|
|
id: 'hnmain',
|
|
border: 0,
|
|
cellPadding: 0,
|
|
cellSpacing: 0,
|
|
width: '85%',
|
|
style: {
|
|
'background-color': '#f6f6ef',
|
|
},
|
|
}, e('tbody', null,
|
|
e(HeaderBar, null),
|
|
e('tr', { height: 10 }),
|
|
e(StoryList, {
|
|
stories,
|
|
})
|
|
))
|
|
);
|
|
}
|
|
|
|
const app = document.getElementById('app');
|
|
|
|
window.render = function render() {
|
|
ReactDOM.render(React.createElement(App, {
|
|
stories: window.stories
|
|
}), app);
|
|
}
|
|
})(); |