Skip to content

Conversation

@Uzlopak
Copy link
Collaborator

@Uzlopak Uzlopak commented Oct 28, 2025

fix #370

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 28, 2025

Open in StackBlitz

npm i https://pkg.pr.new/tinylibs/tinybench@371

commit: 2245bfe

@github-actions
Copy link

github-actions bot commented Oct 28, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
dist/index.js 10.75 KB (+0.42% 🔺) 215 ms (+0.42% 🔺) 71 ms (+4521.06% 🔺) 286 ms

@Uzlopak Uzlopak requested a review from Copilot October 28, 2025 19:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for explicitly setting the async option for benchmark tasks in Tinybench. This allows users to override the automatic async detection behavior, which is useful when a function returns a Promise but should be treated as synchronous (e.g., for API compatibility), or vice versa.

Key Changes:

  • Added an optional async boolean field to the FnOptions interface
  • Updated the Task constructor to respect the explicit async option when provided, falling back to automatic detection otherwise
  • Added comprehensive documentation explaining async detection behavior and how to use the new option

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/types.ts Added async optional field to FnOptions interface with documentation
src/task.ts Modified Task constructor to use explicit async option when provided, falling back to isFnAsyncResource()
README.md Added "Async Detection" section with detailed explanation and usage examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@jerome-benoit jerome-benoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

@Uzlopak Uzlopak merged commit f61b1ee into main Oct 29, 2025
15 checks passed
@Uzlopak Uzlopak deleted the add-async-option branch October 29, 2025 01:52
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.

Avoid isFnAsyncResource calling task functions

3 participants