Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@anyroad/react-component-benchmark
Advanced tools
A component utility for estimating benchmarks of React components
This project aims to provide a method for gathering benchmarks of component tree mount, update, and unmount timings.
Please note that the values returned are estimates. Since this project does not hook into the React renderer directly, the values gathered are not 100% accurate and may vary slightly because they're taken from a wrapping component. That being said, running a large sample set should give you a confident benchmark metric.
Historically, React has provided react-addons-perf
in order to help gain insight into the performance of mounting, updating, and unmounting components. Unfortunately, as of React 16, it has been deprecated. Additionally, before deprecation, it was not usable in production React builds, making it less useful for many applications.
See the examples directory for ideas on how you might integrate this into your own project, whether in your user-interface or your automated tests.
import Benchmark, { BenchmarkType } from 'react-component-benchmark';
class MyComponentBenchmark extends React.Component {
render() {
return (
<div>
<button onClick={this._start}>Run</button>
<Benchmark
component={MyComponent}
componentProps={componentProps}
onComplete={this._handleComplete}
ref={this._setBenchRef}
samples={50}
timeout={10000}
type={BenchmarkType.MOUNT}
/>
</div>
);
}
_start = () => { this._benchmark.start(); };
_handleComplete = (results) => {
console.log(results);
};
_setBenchRef = (ref) => { this._benchmark = ref; };
}
component
: typeof React.ComponentcomponentProps
: object Properties to be given to component
when renderingonComplete
: (x: BenchResultsType) => voidsamples
: number Samples to run (default 50
)timeout
: number Amount of time in milliseconds to stop running (default 10000
)type
: string One of 'mount'
, 'update'
, or 'unmount'
. Also available from BenchmarkType
.See examples/tests for various test integrations.
Note: All times and timestamps are in milliseconds. High resolution times provided when available.
startTime
: number Timestamp of when the run startedendTime
: number Timestamp of when the run completedrunTime
: number Amount of time that it took to run all samples.sampleCount
: number The number of samples actually run. May be less than requested if the timeout
was hit.samples
: Array<{ start, end, elapsed }>max
: number Maximum time elapsedmin
: number Minimum time elapsedmedian
: number Median time elapsedmean
: number Mean time elapsedstdDev
: number Standard deviation of all elapsed timesp70
: number 70th percentile for time elapsed: mean + stdDev
p95
: number 95th percentile for time elapsed: mean + (stdDev * 2)
p99
: number 99th percentile for time elapsed: mean + (stdDev * 3)
FAQs
A component utility for estimating benchmarks of React components
We found that @anyroad/react-component-benchmark demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.