Skip to content

Commit

Permalink
align benchmark to comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls committed Jan 30, 2024
1 parent 70949d1 commit 8e88b6b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/thirdweb/benchmark/contract-read.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* eslint-disable better-tree-shaking/no-top-level-side-effects */
import { Bench } from "tinybench";
import { Contract, getDefaultProvider } from "ethers6";
import { createPublicClient, http } from "viem";
import {
createPublicClient,
http,
getContract as viem_getContract,
} from "viem";
import { mainnet } from "viem/chains";
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
import { createClient, getContract } from "../src";
Expand All @@ -15,14 +19,14 @@ bench.add("thirdweb@alpha", async () => {
clientId: "benchmark",
});

const myContract = getContract({
const contract = getContract({
client,
chainId: 1,
address: USDC_ADDRESS,
});

await totalSupply({
contract: myContract,
contract,
});
});
bench.add("@thirdweb-dev/sdk", async () => {
Expand Down Expand Up @@ -53,11 +57,8 @@ bench.add("viem", async () => {
transport: http(),
});

await client.readContract({
address: USDC_ADDRESS,
abi,
functionName: "totalSupply",
});
const contract = viem_getContract({ address: USDC_ADDRESS, abi, client });
await contract.read.totalSupply();
});
bench.add("ethers@6", async () => {
const abi = ["function totalSupply() view returns (uint256)"];
Expand Down

0 comments on commit 8e88b6b

Please sign in to comment.