{"library":"nv-facutil-simple-test","title":"Simple Function Performance Test Utilities","description":"nv-facutil-simple-test is an early-stage (version 0.0.22) JavaScript utility library designed for straightforward function execution and performance benchmarking. It provides mechanisms to execute synchronous functions (`sync`) and asynchronous functions (`async`) a specified number of times, measuring their execution cost. Additionally, it offers a `cmp` utility to compare the performance of multiple functions against each other. The library aims to offer a minimalistic API for quick, ad-hoc performance tests and basic function verification. Given its pre-1.0 versioning, it is currently in active development with an unspecified release cadence, implying that breaking changes may occur frequently. Its primary differentiator is its directness and simplicity for measuring execution time.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install nv-facutil-simple-test"],"cli":null},"imports":["import { sync } from 'nv-facutil-simple-test';","import { async } from 'nv-facutil-simple-test';","import { cmp } from 'nv-facutil-simple-test';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { sync, async, cmp } from 'nv-facutil-simple-test';\n\n// Example 1: Synchronous function testing\nfunction addNumbers(a, b) {\n    let sum = 0;\n    for (let i = 0; i < 100; i++) {\n        sum += a + b;\n    }\n    return sum;\n}\n\nconsole.log('Synchronous test results:');\nconst syncResult = sync(100000, addNumbers, 5, 10);\nconsole.log(syncResult);\n\n// Example 2: Asynchronous function testing\nfunction delayedGreeting(name, delay) {\n    return new Promise(resolve => {\n        setTimeout(() => resolve(`Hello, ${name} after ${delay}ms`), delay);\n    });\n}\n\nconsole.log('\\nAsynchronous test results (awaiting promise):');\nasync function runAsyncTest() {\n    const asyncResult = await async(3, delayedGreeting, 'World', 100);\n    console.log(asyncResult);\n}\nrunAsyncTest();\n\n// Example 3: Compare performance of multiple functions\nclass Cnode { constructor(a, b) { this.a = a; this.b = b; } }\nfunction Fnode(a, b) { this.a = a; this.b = b; }\nconst new_cnd = (a, b) => new Cnode(a, b);\nconst new_fnd = (a, b) => new Fnode(a, b);\nconst plain_obj = (a, b) => ({ a, b });\n\nconsole.log('\\nComparing object creation methods:');\nconst comparisonResults = cmp(1000000, [new_cnd, new_fnd, plain_obj], 111, 222);\nconsole.log(comparisonResults);\n","lang":"javascript","description":"This quickstart demonstrates how to use `sync` for synchronous tasks, `async` for asynchronous (Promise-based) operations, and `cmp` to benchmark the performance of several functions, illustrating basic usage patterns for each.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}