Skip to content

Conversation

@Uzlopak
Copy link
Collaborator

@Uzlopak Uzlopak commented Nov 10, 2025

should fix #53

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 10, 2025

Open in StackBlitz

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

commit: 1498191

@github-actions
Copy link

github-actions bot commented Nov 10, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
dist/index.js 9.71 KB (+0.4% 🔺) 195 ms (+0.4% 🔺) 14 ms (+183.19% 🔺) 208 ms

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 introduces an AbstractBench interface to improve type safety and refactors the Bench class to expose properties directly instead of through an internal opts object. This change addresses issue #53 by making the benchmark configuration immutable and improving the API design.

Key Changes:

  • Introduced AbstractBench interface defining the public contract for the Bench class
  • Refactored Bench class to expose configuration properties as readonly class members instead of through bench.opts.*
  • Updated all test files to access properties directly (e.g., bench.time instead of bench.opts.time)

Reviewed Changes

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

Show a summary per file
File Description
src/types.ts Adds AbstractBench interface, Concurrency and NowFn type aliases, and updates type definitions
src/bench.ts Refactors Bench class to implement AbstractBench with direct property exposure instead of opts object
src/task.ts Updates Task class to use AbstractBench interface and access properties directly
test/duration.test.ts Updates tests to use bench.now() instead of bench.opts.now()
test/bench-consistency-sync.test.ts Updates tests to use bench.iterations and bench.time instead of bench.opts.*
test/bench-consistency-async.test.ts Updates tests to use bench.iterations and bench.time instead of bench.opts.*
test/sequential.test.ts Updates tests to set concurrency via constructor options and removes dynamic property assignments
test/concurrency.test.ts Splits single test into two separate tests and sets concurrency via constructor

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

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


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

Copy link
Member

@43081j 43081j left a comment

Choose a reason for hiding this comment

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

makes sense to me

im not sure if Abstract makes sense though since i'd expect that to be an abstract class for example. but i have no better suggestions other than BenchLike 😅

@Uzlopak
Copy link
Collaborator Author

Uzlopak commented Nov 11, 2025

Yes you are right. Abstract would be meaning abstract class. Hmm. And IBench sucks because why the I...

@Uzlopak
Copy link
Collaborator Author

Uzlopak commented Nov 11, 2025

renaming to BenchLike. Its an internal type but should not be confusing with abstract classes.

@Uzlopak Uzlopak changed the title fix: introduce and use AbstractBench fix: introduce and use BenchLike interface to decouple task from Bench. Nov 11, 2025
@Uzlopak Uzlopak merged commit c5a0729 into main Nov 11, 2025
22 of 23 checks passed
@Uzlopak Uzlopak deleted the abstractBench branch November 11, 2025 10:38
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.

Circular dependency

3 participants