Skip to content
382 changes: 234 additions & 148 deletions scripts/bench/benchmarks/hacker-news/benchmark.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions scripts/bench/benchmarks/hacker-news/build.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict';

const {
join,
} = require('path');
const {join} = require('path');

async function build(reactPath, asyncCopyTo) {
// copy the UMD bundles
// copy the UMD bundles
await asyncCopyTo(
join(reactPath, 'build', 'dist', 'react.production.min.js'),
join(__dirname, 'react.production.min.js')
Expand Down
17 changes: 12 additions & 5 deletions scripts/bench/benchmarks/hacker-news/generate.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
'use strict';

const fetch = require('node-fetch');
const { writeFileSync } = require('fs');
const {writeFileSync} = require('fs');
const stories = 50;

async function getStory(id) {
const storyRes = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
const storyRes = await fetch(
`https://hacker-news.firebaseio.com/v0/item/${id}.json`
);
return await storyRes.json();
}

async function getTopStories() {
const topStoriesRes = await fetch('https://hacker-news.firebaseio.com/v0/topstories.js');
const topStoriesRes = await fetch(
'https://hacker-news.firebaseio.com/v0/topstories.js'
);
const topStoriesIds = await topStoriesRes.json();

const topStories = [];
Expand All @@ -20,7 +24,10 @@ async function getTopStories() {
topStories.push(await getStory(topStoriesId));
}

writeFileSync('top-stories.json', `window.stories = ${JSON.stringify(topStories)}`);
writeFileSync(
'top-stories.json',
`window.stories = ${JSON.stringify(topStories)}`
);
}

getTopStories();
getTopStories();
1,322 changes: 1,321 additions & 1 deletion scripts/bench/benchmarks/hacker-news/top-stories.js

Large diffs are not rendered by default.

Loading