-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16c6076
commit 018c105
Showing
9 changed files
with
147 additions
and
2 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
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,69 @@ | ||
name: Benchmark | ||
on: | ||
workflow_call: | ||
|
||
permissions: | ||
# deployments permission to deploy GitHub pages website | ||
deployments: write | ||
# contents permission to update benchmark contents in gh-pages branch | ||
contents: write | ||
|
||
env: | ||
CACHE: true | ||
|
||
jobs: | ||
benchmark: | ||
name: Performance regression check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Load environment variables | ||
run: cat .github/.env >> $GITHUB_ENV | ||
|
||
- name: Start validator | ||
uses: metaplex-foundation/actions/start-validator@v1 | ||
with: | ||
node: 18.x | ||
solana: ${{ env.SOLANA_VERSION }} | ||
cache: ${{ env.CACHE }} | ||
|
||
- name: Install dependencies | ||
uses: metaplex-foundation/actions/install-node-dependencies@v1 | ||
with: | ||
folder: ./clients/js | ||
cache: ${{ env.CACHE }} | ||
key: clients-js | ||
|
||
- name: Build | ||
working-directory: ./clients/js | ||
run: pnpm build | ||
|
||
- name: Test | ||
working-directory: ./clients/js | ||
run: pnpm bench | ||
|
||
# Download previous benchmark result from cache (if exists) | ||
- name: Download previous benchmark data | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./cache | ||
key: ${{ runner.os }}-benchmark | ||
|
||
# Run `github-action-benchmark` action | ||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
# What benchmark tool the output.json came from | ||
tool: "customSmallerIsBetter" | ||
# Where the output from the benchmark tool is stored | ||
output-file-path: ./clients/js/output.json | ||
# Where the previous data file is stored | ||
# external-data-json-path: ./cache/benchmark-data.json | ||
# Workflow will fail when an alert happens | ||
fail-on-alert: true | ||
# Access token to deploy GitHub Pages branch | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# Push and deploy GitHub pages branch automatically | ||
auto-push: true |
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 |
---|---|---|
|
@@ -9,3 +9,4 @@ dist | |
.amman | ||
.crates | ||
.bin | ||
clients/js/output.json |
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 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { createUmi as basecreateUmi } from '@metaplex-foundation/umi-bundle-tests'; | ||
import { | ||
mplProjectName, | ||
} from '../src'; | ||
|
||
export const createUmi = async () => (await basecreateUmi()).use(mplProjectName()); |
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,45 @@ | ||
import { generateSigner } from "@metaplex-foundation/umi"; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import test from "ava"; | ||
import { existsSync, readFileSync, writeFileSync } from "fs"; | ||
import { create } from '../src'; | ||
import { createUmi } from "./_setup"; | ||
|
||
test('create a new account', async (t) => { | ||
// Given an Umi instance and a new signer. | ||
const umi = await createUmi(); | ||
const address = generateSigner(umi); | ||
|
||
// When we create a new account. | ||
const tx = await create(umi, { address, arg1: 1, arg2: 2 }).sendAndConfirm(umi); | ||
|
||
const compute = Number((await umi.rpc.getTransaction(tx.signature))?.meta.computeUnitsConsumed); | ||
const account = await umi.rpc.getAccount(address.publicKey); | ||
const space = account.exists ? account.data.length : 0; | ||
|
||
const cuResult = { | ||
name: `CU: ${t.title}`, | ||
unit: "Compute Units", | ||
value: compute, | ||
} | ||
|
||
const spaceResult = { | ||
name: `Space: ${t.title}`, | ||
unit: "Bytes", | ||
value: space, | ||
} | ||
|
||
// Read the results array from output.json | ||
let output = []; | ||
if (existsSync("./output.json")) { | ||
output = JSON.parse(readFileSync("./output.json", 'utf-8')); | ||
} | ||
|
||
// Push the result to the array | ||
output.push(cuResult); | ||
output.push(spaceResult); | ||
// Write the array to output.json | ||
writeFileSync("./output.json", JSON.stringify(output, null, 2)); | ||
|
||
t.pass(); | ||
}); |
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