Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@patchback
Copy link
Contributor

@patchback patchback bot commented Mar 31, 2025

This is a backport of PR #10644 as merged into master (8c4e60b).

What do these changes do?

Add benchmarks for streaming API.

I get asked all the time if someone should use iter_chunked, iter_any, or iter_chunks. Its nice to be able to point people at benchmarks, especially ones they can alter with their numbers and run locally.

Unsurprisingly memcpy is where the performance issues are so avoiding it as much as possible will give better performance. In almost all cases iter_chunks is going to give the best performance if you can trust the chunk sizes aren't going to be too large.

Are there changes in behavior for the user?

no

Is it a substantial burden for the maintainers to support this?

no

<!-- Thank you for your contribution! -->

## What do these changes do?

Add benchmarks for streaming API.

I get asked all the time if someone should use `iter_chunked`,
`iter_any`, or `iter_chunks`. Its nice to be able to point people at
benchmarks, especially ones they can alter with their numbers and run
locally.

Unsurprisingly `memcpy` is where the performance issues are so avoiding
it as much as possible will give better performance. In almost all cases
`iter_chunks` is going to give the best performance if you can trust the
chunk sizes aren't going to be too large.

## Are there changes in behavior for the user?

no

## Is it a substantial burden for the maintainers to support this?
no

(cherry picked from commit 8c4e60b)
@patchback patchback bot requested a review from asvetlov as a code owner March 31, 2025 02:08
@bdraco bdraco enabled auto-merge (squash) March 31, 2025 02:09
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 31, 2025

CodSpeed Performance Report

Merging #10645 will not alter performance

Comparing patchback/backports/3.11/8c4e60b04a8edea54d6dcbfbd201aa3204ea6c13/pr-10644 (7150de4) with 3.11 (bc813e6)

Summary

✅ 47 untouched benchmarks
🆕 4 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 test_ten_streamed_responses_iter_any[pyloop] N/A 21.5 ms N/A
🆕 test_ten_streamed_responses_iter_chunked_4096[pyloop] N/A 27.9 ms N/A
🆕 test_ten_streamed_responses_iter_chunked_65536[pyloop] N/A 22.9 ms N/A
🆕 test_ten_streamed_responses_iter_chunks[pyloop] N/A 16.1 ms N/A

@codecov
Copy link

codecov bot commented Mar 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.09%. Comparing base (bc813e6) to head (7150de4).
Report is 47 commits behind head on 3.11.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.11   #10645   +/-   ##
=======================================
  Coverage   98.09%   98.09%           
=======================================
  Files         126      126           
  Lines       37493    37577   +84     
  Branches     4525     4541   +16     
=======================================
+ Hits        36779    36863   +84     
  Misses        538      538           
  Partials      176      176           
Flag Coverage Δ
CI-GHA 97.98% <100.00%> (+<0.01%) ⬆️
OS-Linux 97.68% <100.00%> (+<0.01%) ⬆️
OS-Windows 94.75% <100.00%> (+0.01%) ⬆️
OS-macOS 96.81% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 96.68% <100.00%> (+0.01%) ⬆️
Py-3.10.16 97.24% <100.00%> (+0.04%) ⬆️
Py-3.11.11 97.27% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 96.75% <100.00%> (+0.01%) ⬆️
Py-3.12.9 97.71% <100.00%> (-0.04%) ⬇️
Py-3.13.2 97.75% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 96.58% <95.23%> (-0.01%) ⬇️
Py-3.9.21 97.14% <95.23%> (+0.04%) ⬆️
Py-pypy7.3.16 96.71% <100.00%> (-0.01%) ⬇️
VM-macos 96.81% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 97.68% <100.00%> (+<0.01%) ⬆️
VM-windows 94.75% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco bdraco merged commit b93993d into 3.11 Mar 31, 2025
36 checks passed
@bdraco bdraco deleted the patchback/backports/3.11/8c4e60b04a8edea54d6dcbfbd201aa3204ea6c13/pr-10644 branch March 31, 2025 02:29
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