mirror of
https://github.com/NotAShelf/nix-evaluator-stats.git
synced 2026-04-12 14:27:41 +00:00
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Id40b5f5ccb55a8a1ea2793192a38f0256a6a6964
27 lines
822 B
Markdown
27 lines
822 B
Markdown
# @ns/core
|
|
|
|
Core types and parsing logic for Nix evaluator statistics. This package is
|
|
framework-agnostic and can be used in any JavaScript/TypeScript environment.
|
|
|
|
## Usage
|
|
|
|
```typescript
|
|
import { calculateChange, parseStats, StatsData } from "@ns/core";
|
|
|
|
// Parse raw stats from Nix
|
|
const raw = JSON.parse(statsJson);
|
|
const stats: StatsData = parseStats(raw);
|
|
|
|
console.log(`CPU Time: ${stats.cpuTime}s`);
|
|
console.log(`Expressions: ${stats.nrExprs}`);
|
|
|
|
// Compare two values
|
|
const change = calculateChange(stats.nrThunks, previousStats.nrThunks);
|
|
console.log(`Thunks changed by ${change.percent.toFixed(2)}%`);
|
|
```
|
|
|
|
## Version Compatibility
|
|
|
|
The parser handles different Nix implementations (Nix, Lix, Snix, etc.) by
|
|
checking for field existence in the raw JSON, since not all implementations
|
|
expose the same statistics.
|