Skip to content

Commit

Permalink
refactor(benchmarks): organize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Oct 6, 2021
1 parent 0de0040 commit c70a6e6
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 39 deletions.
2 changes: 1 addition & 1 deletion benchmarks/benchmark.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import Benchmark from 'benchmark';
import _ from 'lodash';

// avoid `Cannot read property 'parentNode' of undefined` error in runScript
const script = document.createElement('script');
Expand Down
51 changes: 21 additions & 30 deletions benchmarks/main.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'style.css';

import { m, createElement, style, kebab, patch } from '../src/index';

import { createElement, patch } from '../src/index';
import appendManyRowsToLargeTable from './suites/appendManyRowsToLargeTable';
import clearRows from './suites/clearRows';
import createManyRows from './suites/createManyRows';
Expand Down Expand Up @@ -39,6 +37,19 @@ const suites = [
}),
);

const generateLogMarkdown = () =>
`Benchmarks compiled on \`${new Date().toLocaleString()}\`\n\n**UA:** ${
navigator.userAgent
}\n\n---\n\n${[...logs]
.map((logGroup) => {
const logGroupCopy = [...logGroup];
const title = logGroupCopy.shift();
return `${title.replace('Running: ', '').split(' - ')[0]}\n\n\`\`\`\n${logGroupCopy.join(
'\n',
)}\n\`\`\`\n`;
})
.join('\n')}`;

const vnode = () => (
<div>
{suites.map((suite) => {
Expand Down Expand Up @@ -72,19 +83,7 @@ const vnode = () => (
</button>{' '}
<button
onclick={async () => {
navigator.clipboard.writeText(
`Benchmarks compiled on \`${new Date().toLocaleString()}\`\n\n**UA:** ${
navigator.userAgent
}\n\n---\n\n${[...logs]
.map((logGroup) => {
const logGroupCopy = [...logGroup];
const title = logGroupCopy.shift();
return `${
title.replace('Running: ', '').split(' - ')[0]
}\n\n\`\`\`\n${logGroupCopy.join('\n')}\n\`\`\`\n`;
})
.join('\n')}`,
);
navigator.clipboard.writeText(generateLogMarkdown());
}}
>
📋
Expand All @@ -94,7 +93,11 @@ const vnode = () => (
<div style={{ paddingTop: '20px' }}>
{logs.map(
(logGroup) =>
logGroup.length && m('pre', undefined, [m('code', undefined, [logGroup.join('\n')])]),
logGroup.length && (
<pre>
<code>{logGroup.join('\n')}</code>
</pre>
),
)}
</div>
</details>
Expand All @@ -114,19 +117,7 @@ const vnode = () => (
</button>{' '}
<button
onclick={async () => {
navigator.clipboard.writeText(
`Benchmarks compiled on \`${new Date().toLocaleString()}\`\n\n**UA:** ${
navigator.userAgent
}\n\n---\n\n${[...logs]
.map((logGroup) => {
const logGroupCopy = [...logGroup];
const title = logGroupCopy.shift();
return `${
title.replace('Running: ', '').split(' - ')[0]
}\n\n\`\`\`\n${logGroupCopy.join('\n')}\n\`\`\`\n`;
})
.join('\n')}`,
);
navigator.clipboard.writeText(generateLogMarkdown());
}}
>
📋
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/suites/appendManyRowsToLargeTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @description appending 1,000 to a table of 10,000 rows.
*/

import { Suite } from '../benchmark';
import { createElement, patch } from '../../src/index';
import { Suite } from '../benchmark';
import { buildData } from '../data';

const data = buildData(10000);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/suites/clearRows.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @description clearing a table with 1,000 rows
*/

import { Suite } from '../benchmark';
import { createElement, patch } from '../../src/index';
import { Suite } from '../benchmark';
import { buildData } from '../data';

const data = buildData(1000);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/suites/createManyRows.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @description creating 10,000 rows
*/

import { Suite } from '../benchmark';
import { createElement, patch } from '../../src/index';
import { Suite } from '../benchmark';
import { buildData } from '../data';

const data = buildData(10000);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/suites/createRows.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @description creating 1,000 rows
*/

import { Suite } from '../benchmark';
import { createElement, patch } from '../../src/index';
import { Suite } from '../benchmark';
import { buildData } from '../data';

const data = buildData(10000);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/suites/partialUpdate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @description updating every 10th row for 1,000 rows
*/

import { Suite } from '../benchmark';
import { createElement, patch, UPDATE } from '../../src/index';
import { Suite } from '../benchmark';
import { buildData } from '../data';

const data = buildData(1000);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/suites/removeRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @description removing one row
*/

import { createElement, DELETE, patch } from '../../src/index';
import { Suite } from '../benchmark';
import { createElement, patch, DELETE } from '../../src/index';
import { buildData } from '../data';

const data = buildData(1000);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/suites/replaceAllRows.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @description updating all 1,000 rows
*/

import { Suite } from '../benchmark';
import { createElement, patch } from '../../src/index';
import { Suite } from '../benchmark';
import { buildData } from '../data';

const shuffleArray = (array) => {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/suites/swapRows.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @description swap 2 rows for table with 1,000 rows
*/

import { createElement, patch, UPDATE } from '../../src/index';
import { Suite } from '../benchmark';
import { m, createElement, patch, VFlags, UPDATE } from '../../src/index';
import { buildData } from '../data';

const data = buildData(1000);
Expand Down

0 comments on commit c70a6e6

Please sign in to comment.