Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@jalik/benchmark
Advanced tools
To measure a single function, use measure(func, iterations: number): MeasureResult
.
import { measure } from "@jalik/benchmark";
function logHelloWorld() {
console.log('hello world');
}
// Run function 1000 times
const result = measure(logHelloWorld, 1000);
Which returns a MeasureResult
object defined as below:
interface MeasureResult {
average: number;
fastest: number;
ips: number;
ipsAccuracy: number;
ipsRounded: number;
iterations: number;
median: number;
slowest: number;
total: number;
}
You can show formatted result in the console by using logMeasureResult(result: MeasureResult)
,
which outputs something like this:
iterations/s: 82 ±-0.36%
total: 1224.95 ms
average: 12.25 ms
median: 11.93 ms
fastest: 11.58 ms
slowest: 24.43 ms
To measure several functions, use benchmark(funcs, iterations: number): BenchmarkResult
.
import { benchmark } from "@jalik/benchmark";
function incrementPlusPlus() {
for (let i = 0; i < 10000; i++) {
// do something
}
}
function incrementPlusEqual() {
for (let i = 0; i < 10000; i += 1) {
// do something
}
}
const funcs = {
incrementPlusPlus,
incrementPlusEqual,
};
// Run each function 1000 times
const result = benchmark(funcs, 1000);
Which returns a BenchmarkResult
object defined as below:
interface BenchmarkResult {
[key: string]: MeasureResult;
}
History of releases is in the changelog.
The code is released under the MIT License.
v1.0.0 (2020-04-16)
FAQs
Utilities to benchmark code.
We found that @jalik/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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.