-
-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: .extend performance * chore: format * test(types): bench * chore: ignore * chore: up * chore: up --------- Co-authored-by: tmm <[email protected]>
- Loading branch information
Showing
22 changed files
with
192 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"viem": patch | ||
--- | ||
|
||
Improved `.extend` performance with `publicActions` and other large types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ _esm | |
_types | ||
*.local | ||
.DS_Store | ||
.attest | ||
.eslintcache | ||
.next | ||
bench | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { bench } from '@arktype/attest' | ||
|
||
import { | ||
baycContractConfig, | ||
usdcContractConfig, | ||
} from '../../../test/src/abis.js' | ||
import { anvil } from '../../chains/index.js' | ||
import { createClient } from '../../clients/createClient.js' | ||
import { http } from '../../clients/transports/http.js' | ||
import { multicall } from './multicall.js' | ||
|
||
bench('multicall return type', async () => { | ||
const client = createClient({ chain: anvil, transport: http() }) | ||
const res = multicall(client, { | ||
allowFailure: false, | ||
contracts: [ | ||
{ | ||
...usdcContractConfig, | ||
functionName: 'totalSupply', | ||
}, | ||
{ | ||
...usdcContractConfig, | ||
functionName: 'balanceOf', | ||
args: ['0x...'], | ||
}, | ||
{ | ||
...baycContractConfig, | ||
functionName: 'name', | ||
}, | ||
], | ||
}) | ||
return {} as typeof res | ||
}).types([192503, 'instantiations']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { bench } from '@arktype/attest' | ||
|
||
import { usdcContractConfig } from '../../../test/src/abis.js' | ||
import { anvil } from '../../chains/index.js' | ||
import { createClient } from '../../clients/createClient.js' | ||
import { http } from '../../clients/transports/http.js' | ||
import { readContract } from './readContract.js' | ||
|
||
bench('readContract return type', async () => { | ||
const client = createClient({ chain: anvil, transport: http() }) | ||
const res = readContract(client, { | ||
...usdcContractConfig, | ||
functionName: 'balanceOf', | ||
args: ['0x...'], | ||
}) | ||
return {} as typeof res | ||
}).types([152288, 'instantiations']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { bench } from '@arktype/attest' | ||
|
||
import { createClient } from './createClient.js' | ||
import { createPublicClient } from './createPublicClient.js' | ||
import { publicActions } from './decorators/public.js' | ||
import { http } from './transports/http.js' | ||
|
||
bench('createPublicClient', () => { | ||
const client = createPublicClient({ transport: http() }) | ||
return {} as typeof client | ||
}).types([13470, 'instantiations']) | ||
|
||
bench('createClient.extend + publicActions', () => { | ||
const client = createClient({ transport: http() }).extend(publicActions) | ||
return {} as typeof client | ||
}).types([246356, 'instantiations']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { bench } from '@arktype/attest' | ||
|
||
import { createClient } from './createClient.js' | ||
import { createTestClient } from './createTestClient.js' | ||
import { testActions } from './decorators/test.js' | ||
import { http } from './transports/http.js' | ||
|
||
bench('createTestClient', () => { | ||
const client = createTestClient({ mode: 'anvil', transport: http() }) | ||
return {} as typeof client | ||
}).types([668, 'instantiations']) | ||
|
||
bench('createClient.extend + testActions', () => { | ||
const client = createClient({ transport: http() }).extend( | ||
testActions({ mode: 'anvil' }), | ||
) | ||
return {} as typeof client | ||
}).types([6275, 'instantiations']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { bench } from '@arktype/attest' | ||
|
||
import { createClient } from './createClient.js' | ||
import { createWalletClient } from './createWalletClient.js' | ||
import { walletActions } from './decorators/wallet.js' | ||
import { http } from './transports/http.js' | ||
|
||
bench('createWalletClient', () => { | ||
const client = createWalletClient({ transport: http() }) | ||
return {} as typeof client | ||
}).types([1384, 'instantiations']) | ||
|
||
bench('createClient.extend + walletActions', () => { | ||
const client = createClient({ transport: http() }).extend(walletActions) | ||
return {} as typeof client | ||
}).types([193153, 'instantiations']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { globby } from 'globby' | ||
import { tsImport } from 'tsx/esm/api' | ||
|
||
const paths = await globby(['src/**/*.bench-d.ts']) | ||
for (const path of paths) { | ||
await tsImport(`../${path}`, import.meta.url) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.