Skip to content

Commit 210cb88

Browse files
authored
Merge branch 'main' into enforce_encryption_dfx_install
2 parents 27b0d50 + f868beb commit 210cb88

File tree

9 files changed

+50
-15
lines changed

9 files changed

+50
-15
lines changed

.github/scripts/analyze_benchmarks/extractor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { readFile } from 'fs/promises';
22

33
export type BenchmarkEntry = {
4-
instructions: { __bigint__: string };
4+
instructions: string;
55
method_name: string;
6-
timestamp: { __bigint__: string };
6+
timestamp: string;
77
};
88

99
type VersionBenchmarks = {

.github/scripts/analyze_benchmarks/index.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,34 @@ async function analyzeBenchmarksForVersion(
4949
/**
5050
* Runs the benchmark analysis for a specified version or current version
5151
* @param specifiedVersion Optional version to analyze. If not provided, uses current package version
52+
* @param debugMode If true, throws errors instead of writing them to markdown
5253
*/
53-
async function runBenchmarkAnalysis(specifiedVersion?: string): Promise<void> {
54+
async function runBenchmarkAnalysis(
55+
specifiedVersion?: string,
56+
debugMode: boolean = false
57+
): Promise<void> {
5458
const versionToAnalyze = specifiedVersion ?? currentAzleVersion;
5559
console.info('Analyzing benchmarks...');
5660
try {
5761
const statistics = await analyzeBenchmarksForVersion(versionToAnalyze);
5862
await reportResults(statistics, versionToAnalyze);
5963
} catch (error) {
60-
const errorMessage =
61-
error instanceof Error ? error.message : String(error);
62-
await reportErrorResult(errorMessage, versionToAnalyze);
64+
if (debugMode) {
65+
// In debug mode, throw the error to get stack traces and immediate feedback
66+
throw error;
67+
} else {
68+
// In normal mode, write error to markdown for PR visibility
69+
const errorMessage =
70+
error instanceof Error ? error.message : String(error);
71+
await reportErrorResult(errorMessage, versionToAnalyze);
72+
}
6373
}
6474
console.info(`Report generated at ${MARKDOWN_FILE}`);
6575
}
6676

67-
runBenchmarkAnalysis(process.argv[2]);
77+
// Parse command line arguments
78+
const args = process.argv.slice(2);
79+
const debugMode = args.includes('--debug') === true;
80+
const versionArg = args.find((arg) => arg.startsWith('--') === false);
81+
82+
runBenchmarkAnalysis(versionArg, debugMode);

.github/scripts/analyze_benchmarks/markdown.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,24 @@ export async function generateMarkdownReport(): Promise<string> {
1616
})
1717
);
1818

19-
return `# Benchmarks
19+
return `<!--
20+
This file is auto-generated by .github/scripts/analyze_benchmarks/markdown.ts
21+
Do not edit this file manually. Changes will be overwritten.
22+
-->
23+
24+
# Benchmarks
25+
26+
## Purpose and Usage
27+
28+
This document tracks high-level performance changes across Azle versions for comparison between releases.
29+
30+
**For detailed benchmarks showing how different Candid data types perform, see the [benchmarks example](examples/stable/test/end_to_end/candid_rpc/benchmarks/benchmarks.md).** This is the best resource for understanding day-to-day performance in your Azle applications.
2031
2132
${generateVersionTables(sortedBenchmarks)}
2233
2334
---
24-
*Report generated automatically by Azle*`;
35+
36+
_Report generated automatically by Azle_`;
2537
}
2638

2739
function generateVersionTables(

.github/scripts/analyze_benchmarks/statistics.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ const BASELINE_EFFICIENCY_WEIGHTS = {
2323
* @returns Statistical analysis of the benchmark data
2424
*/
2525
export function calculateVersionStatistics(
26-
entries: BenchmarkEntry[]
26+
entries: BenchmarkEntry[] | undefined
2727
): Statistics {
28-
const instructions = entries.map((entry) =>
29-
Number(entry.instructions.__bigint__)
30-
);
28+
if (entries === undefined || entries.length === 0) {
29+
throw new Error('No benchmark entries found for this version');
30+
}
31+
32+
const instructions = entries.map((entry) => Number(entry.instructions));
3133

3234
return calculateStatistics(instructions);
3335
}

benchmarks.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Benchmarks
22

3+
## Purpose and Usage
4+
5+
This document tracks high-level performance changes across Azle versions for comparison between releases.
6+
7+
**For detailed benchmarks showing how different Candid data types perform, see the [benchmarks example](examples/stable/test/end_to_end/candid_rpc/benchmarks/benchmarks.md).** This is the best resource for understanding day-to-day performance in your Azle applications.
8+
39
## Version `0.30.0`
410

511
<table>
4.88 KB
Binary file not shown.
1.95 KB
Binary file not shown.

src/stable/build/commands/build/javascript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function experimentalMessage(importName: string): string {
223223
function handleBenchmarking(): string {
224224
return /*TS*/ `
225225
if (globalThis.process !== undefined && globalThis.process.env.AZLE_RECORD_BENCHMARKS === 'true') {
226-
const methodMeta = canisterClassMeta.methodMeta;
226+
const methodMeta = globalThis._azleCanisterClassMeta.methodMeta;
227227
228228
const canisterMethodNames = Object.entries(methodMeta).reduce((acc, [key, value]) => {
229229
if (value === undefined) {

src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/rand_bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn get_function(ctx: Ctx) -> Result<Function> {
1212

1313
let mut bytes = vec![0; byte_length];
1414

15-
rng.fill_bytes(bytes.as_mut_slice());
15+
rng.fill_bytes(&mut bytes);
1616

1717
TypedArray::<u8>::new(ctx.clone(), bytes)
1818
})

0 commit comments

Comments
 (0)