Skip to content

Add benchmarks using upstream bench definitions/patterns#53

Open
skeet70 wants to merge 6 commits intomainfrom
benches
Open

Add benchmarks using upstream bench definitions/patterns#53
skeet70 wants to merge 6 commits intomainfrom
benches

Conversation

@skeet70
Copy link
Copy Markdown
Member

@skeet70 skeet70 commented Mar 27, 2026

Numbers look pretty good (see the benches/README). I also temporarily added some benches that let me compare v0.2.1 vs current main, because I was curious what impact those changes had (and the new benchmark suite didn't allow for apples to apples comparisons with 0.2.1, no uniffi_benchmarks available there).

Primitive Array Roundtrips

On v0.2.1 primitive vectors like Vec<i32> generate as List<Integer> (boxed).
On main they generate as int[] (primitive arrays).

Benchmark v0.2.1 (ns/op) main (ns/op) Delta
roundtripI32 (10) 10,760 +/- 4,294 10,119 +/- 3,897 ~same
roundtripI32 (100) 10,705 +/- 1,382 10,861 +/- 5,825 ~same
roundtripI32 (10k) 84,603 +/- 3,498 28,302 +/- 2,224 3x faster
roundtripI64 (10) 9,349 +/- 1,762 10,403 +/- 4,351 ~same
roundtripF64 (10) 11,935 +/- 6,802 10,037 +/- 2,895 ~same
roundtripU32 (10) 9,468 +/- 1,016 10,071 +/- 4,002 ~same
roundtripStrings (10) 11,572 +/- 3,041 10,395 +/- 2,644 ~same
sumI32 (10) 6,950 +/- 2,442 6,246 +/- 2,635 ~same
sumI32 (100) 6,603 +/- 1,308 6,241 +/- 1,873 ~same
sumI32 (10k) 41,144 +/- 22,768 19,522 +/- 1,927 ~2x faster
sumI64 (10) 7,167 +/- 5,457 6,251 +/- 3,487 ~same
sumF64 (10) 6,886 +/- 2,707 6,525 +/- 2,801 ~same

Async (CompletableFuture)

v0.2.1 used spinlock-based polling. Main uses executor-based async.

Benchmark v0.2.1 (ns/op) main (ns/op) Delta  
asyncNoop 14,448 +/- 713 12,288 +/- 342 ~15% faster  
asyncReturn42 14,413 +/- 482 12,353 +/- 286 ~14% faster  
asyncReturnString 19,629 +/- 2,479 16,437 +/- 1,890 ~16% faster  
asyncRoundtripI32 22,309 +/- 3,456 21,109 +/- 3,723 ~same  
asyncRoundtripString 21,804 +/- 2,498 21,132 +/- 3,451 ~same  

@skeet70 skeet70 requested a review from a team as a code owner March 27, 2026 19:02
@skeet70 skeet70 requested review from BobWall23 and giarc3 and removed request for a team and BobWall23 March 27, 2026 19:02
@github-actions
Copy link
Copy Markdown

File Coverage Lines
All files 90% 90%

Minimum allowed coverage is 0%

Generated by 🐒 cobertura-action against 308bc12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants