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

test: Add an improved benchmark util for typescript #3959

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

mat-if
Copy link
Contributor

@mat-if mat-if commented Jun 9, 2023

Summary

This function does a few things:

  • Has a configurable warm-up period, to settle V8 hot-path optimizations and whatever else
  • Has a configurable number of iterations which is used to collect aggregate information
  • Calculates the min, max, avg, median across the iterations. Does not include the warm-up iterations
  • Renders the aggregate stats

Example usage:

      const results = await BenchUtils.withSegmentIterations(10, 100, async () => {
        const _x = await tsPool.decryptNotes(payload)
      })

      const title = `[DecryptNotes: workers: ${test.workers}, notes: ${
        test.notes
      }, canDecrypt: ${test.canDecrypt.toString()}]`
      console.log(BenchUtils.renderSegmentAggregate(results, title))

Example output:

[DecryptNotes: workers: 1, notes: 5, canDecrypt: true]
Iterations: 100
Time: min: 0.0463ms, avg: 0.0668ms, median: 0.0808ms, max 0.3325ms
Heap: min: 12.28 KiB, avg: 12.39 KiB, median: 18.50 KiB, max 15.26 KiB
Rss: min: 0 B, avg: 983 B, median: 0 B, max 16.00 KiB
Mem: min: 12.28 KiB, avg: 13.35 KiB, median: 18.50 KiB, max 30.57 KiB

Testing Plan

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and
what additional work is required, if any.

[ ] Yes

This function does a few things:
- Has a configurable warm-up period, to settle V8 hot-path optimizations
  and whatever else
- Has a configurable number of iterations which is used to collect
  aggregate information
- Calculates the min, max, avg, median across the iterations. Does not
  include the warm-up iterations
- Renders the aggregate stats
@mat-if mat-if requested a review from a team as a code owner June 9, 2023 16:51
Copy link
Contributor

@EvanJRichard EvanJRichard left a comment

Choose a reason for hiding this comment

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

So fresh, so clean.

return 0
}

// TODO(mat): We can use values.toSorted() when we set NodeJS min version to 20
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking out loud, seems worth to expedite bumping the min version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far, we've been following the LTS releases of Node: https://nodejs.dev/en/about/releases/

Which means, we'll be upgrading to 20 in October! 🎉

@mat-if mat-if merged commit b2efb1a into staging Jun 9, 2023
@mat-if mat-if deleted the mat/ts-benchmark-function branch June 9, 2023 19:44
jowparks pushed a commit that referenced this pull request Jun 21, 2023
This function does a few things:
- Has a configurable warm-up period, to settle V8 hot-path optimizations
  and whatever else
- Has a configurable number of iterations which is used to collect
  aggregate information
- Calculates the min, max, avg, median across the iterations. Does not
  include the warm-up iterations
- Renders the aggregate stats
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