Skip to content

Commit

Permalink
chore: benchmarks (#2318)
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Qun authored Jan 1, 2024
1 parent 5569c8b commit 842b8f8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
34 changes: 17 additions & 17 deletions benchmarks/simple-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ const createStateWithAtoms = (n: number) => {
}

const main = async () => {
for (const n of [2, 3, 4, 5, 6]) {
await suite(
`simple-read-${n}`,
await suite(
'simple-read',
...[2, 3, 4, 5, 6].map((n) =>
add(`atoms=${10 ** n}`, () => {
const [store, targetAtom] = createStateWithAtoms(10 ** n)
return () => store.get(targetAtom)
}),
cycle(),
complete(),
save({
folder: __dirname,
file: `simple-read-${n}`,
format: 'json',
}),
save({
folder: __dirname,
file: `simple-read-${n}`,
format: 'chart.html',
}),
)
}
),
cycle(),
complete(),
save({
folder: __dirname,
file: 'simple-read',
format: 'json',
}),
save({
folder: __dirname,
file: 'simple-read',
format: 'chart.html',
}),
)
}

main()
34 changes: 17 additions & 17 deletions benchmarks/simple-write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ const createStateWithAtoms = (n: number) => {
}

const main = async () => {
for (const n of [2, 3, 4, 5, 6]) {
await suite(
`simple-write-${n}`,
await suite(
'simple-write',
...[2, 3, 4, 5, 6].map((n) =>
add(`atoms=${10 ** n}`, () => {
const [store, targetAtom] = createStateWithAtoms(10 ** n)
return () => store.set(targetAtom, (c) => c + 1)
}),
cycle(),
complete(),
save({
folder: __dirname,
file: `simple-write-${n}`,
format: 'json',
}),
save({
folder: __dirname,
file: `simple-write-${n}`,
format: 'chart.html',
}),
)
}
),
cycle(),
complete(),
save({
folder: __dirname,
file: 'simple-write',
format: 'json',
}),
save({
folder: __dirname,
file: 'simple-write',
format: 'chart.html',
}),
)
}

main()
34 changes: 17 additions & 17 deletions benchmarks/subscribe-write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ const createStateWithAtoms = (n: number) => {
}

const main = async () => {
for (const n of [2, 3, 4, 5, 6]) {
await suite(
`subscribe-write-${n}`,
await suite(
'subscribe-write',
...[2, 3, 4, 5, 6].map((n) =>
add(`atoms=${10 ** n}`, () => {
cleanup()
const [store, targetAtom] = createStateWithAtoms(10 ** n)
return () => store.set(targetAtom, (c) => c + 1)
}),
cycle(),
complete(),
save({
folder: __dirname,
file: `subscribe-write-${n}`,
format: 'json',
}),
save({
folder: __dirname,
file: `subscribe-write-${n}`,
format: 'chart.html',
}),
)
}
),
cycle(),
complete(),
save({
folder: __dirname,
file: 'subscribe-write',
format: 'json',
}),
save({
folder: __dirname,
file: 'subscribe-write',
format: 'chart.html',
}),
)
}

main()

1 comment on commit 842b8f8

@vercel
Copy link

@vercel vercel bot commented on 842b8f8 Jan 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.