Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to retrieve results #4

Closed
ecstrema opened this issue Aug 29, 2022 · 4 comments
Closed

Document how to retrieve results #4

ecstrema opened this issue Aug 29, 2022 · 4 comments

Comments

@ecstrema
Copy link
Contributor

ecstrema commented Aug 29, 2022

Add a working example in readme

The current example does the test, but doesn't log nor output anything to a file. Trying it was very deceiving, although after some research, the lib seems great!

Original issue

Reproduction:

// test.js
import { Bench } from "tinybench";

const bench = new Bench({ time: 100 });

bench
  .add("Test tinybench", () => {
    let a = 8;
    let b = 1;
    const c = a;
    a = b;
    b = c;
  });

console.log(await bench.run());
node test,js

Output:

[ m {} ]

Expected output:

Benchmark results?

@ecstrema
Copy link
Contributor Author

I've tried as CJS too, which wasn't supported because of top-level await.

$ node --version
v16.14.2

@ecstrema
Copy link
Contributor Author

First time using a benchmarking lib here.

So apparently i need to listen to "cycle" event.

Are there any docs for it?

I suggest the Readme sample to be a working example.

@ecstrema ecstrema changed the title Working lib? Document how to retrieve results Aug 29, 2022
@Aslemammad
Copy link
Member

Aslemammad commented Aug 29, 2022

You do not need the cycle event, it's for listening!

to see the result as mentioned in the docs, you can try accessing Task.result (with bench.tasks, bench.getTask, ...) property after bench.run.

You can write your understandings in the docs and I'll merge it.

@ecstrema
Copy link
Contributor Author

You can write your understandings in the docs and I'll merge it.

sounds good

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

No branches or pull requests

2 participants