Skip to content

Commit bcb4dbc

Browse files
committed
chore: wip
1 parent b64ac5d commit bcb4dbc

File tree

8 files changed

+124
-30
lines changed

8 files changed

+124
-30
lines changed

.performance-summary.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,27 @@ Moved alphabet and digit arrays to static readonly properties.
6060
| Email Generation | 1.96M ops/s | 567.44K ops/s | **3.5x faster** |
6161
| Complex Objects (10k) | 7.97ms | 52.39ms | **6.6x faster** |
6262

63+
## 📦 Package Size Comparison
64+
65+
| Library | Published Size | Files | vs nanofaker |
66+
|---------|----------------|-------|--------------|
67+
| **nanofaker** | **174 KB** | **38** | Baseline |
68+
| casual | 408 KB | 75 | 2.4x larger |
69+
| @ngneat/falso | 1.16 MB | 399 | 6.7x larger |
70+
| chance | 2.08 MB | 164 | 12.0x larger |
71+
| @faker-js/faker | 4.29 MB | 231 | **24.7x larger** |
72+
73+
**Size Advantages:**
74+
-**24.7x smaller** than @faker-js/faker (saves 4.12 MB)
75+
-**6.1x fewer files** than @faker-js/faker
76+
-**Faster installation** - 174 KB vs 4.29 MB
77+
-**Better CI/CD** - Saves ~12.3 GB/month bandwidth (100 runs/day)
78+
6379
## 🎯 Trade-offs
6480

6581
### Benefits
6682
-**6.57x average speedup** vs @faker-js/faker
83+
-**24.7x smaller package size** vs @faker-js/faker
6784
-**100% win rate** against all competitors
6885
- ✅ Maintains API compatibility
6986
- ✅ Maintains seeded reproducibility

BENCHMARKS.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,26 @@ Generates 10,000 complete user objects with:
116116

117117
## Libraries Tested
118118

119-
- **nanofaker** (this library) - Performance-focused faker with 26 locales
120-
- **@faker-js/faker** v10.0.0 - Most popular faker library
121-
- **chance** v1.1.13 - Popular random generator
122-
- **casual** v1.6.2 - Lightweight fake data generator
123-
- **@ngneat/falso** v7.4.0 - TypeScript-first random data generator
119+
| Library | Version | Published Size | Files |
120+
|---------|---------|----------------|-------|
121+
| **nanofaker** | (core) | **174 KB** | **38** |
122+
| **casual** | v1.6.2 | 408 KB | 75 |
123+
| **@ngneat/falso** | v7.4.0 | 1.16 MB | 399 |
124+
| **chance** | v1.1.13 | 2.08 MB | 164 |
125+
| **@faker-js/faker** | v10.0.0 | 4.29 MB | 231 |
126+
127+
### Package Size Advantages
128+
129+
nanofaker is **dramatically smaller** than all competitors:
130+
131+
- **24.7x smaller** than @faker-js/faker (saves 4.12 MB)
132+
- **12.0x smaller** than chance (saves 1.91 MB)
133+
- **6.7x smaller** than @ngneat/falso (saves 1.01 MB)
134+
- **2.4x smaller** than casual (saves 234 KB)
135+
136+
Even compared to the smallest competitor (casual), nanofaker is **2.4x smaller** while offering 26 full locales vs limited support.
137+
138+
📦 See [PACKAGE-SIZES.md](./PACKAGE-SIZES.md) for detailed size comparison and analysis.
124139

125140
## Key Takeaways
126141

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,20 @@ See the [CLI documentation](https://nanofaker.stacksjs.org/cli) for complete det
335335

336336
## Performance Benchmarks
337337

338-
nanofaker is designed for performance. We benchmark against all major JavaScript/TypeScript faker libraries:
338+
nanofaker is designed for performance and efficiency:
339339

340-
**Results Summary:**
340+
**Performance:**
341341
-**9 out of 9 benchmarks won** (100% win rate!)
342342
-**6.57x faster than @faker-js/faker** on average
343343
- 🚀 **39.63M ops/s** for city generation
344344
- 📊 **7.97ms** to generate 10,000 complex user objects
345345

346+
**Package Size:**
347+
- 📦 **174 KB** published (core package only)
348+
- 🎯 **24.7x smaller than @faker-js/faker** (4.29 MB)
349+
- 🪶 **38 files** vs 231 in @faker-js/faker
350+
- 🔌 **Modular locales** - install only what you need
351+
346352
### Quick Comparison
347353

348354
| Operation | nanofaker | @faker-js/faker | Speedup |
@@ -366,7 +372,8 @@ bun run bench
366372
# - @ngneat/falso
367373
```
368374

369-
📊 See [BENCHMARKS.md](./BENCHMARKS.md) for detailed results and methodology.
375+
**Detailed Documentation:**
376+
- 📊 [BENCHMARKS.md](./BENCHMARKS.md) - Complete performance results and methodology
370377

371378
## Testing
372379

docs/comparison.md

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,82 @@ How nanofaker compares to other popular faker libraries.
66

77
| Feature | nanofaker | @faker-js/faker | Laravel Faker | Chance.js | Casual |
88
|---------|-----------|-----------------|---------------|-----------|--------|
9-
| **Bundle Size** | ~50KB | ~200-500KB | N/A (PHP) | ~100KB | ~80KB |
9+
| **Published Size** | 174 KB | 4.29 MB | N/A (PHP) | 2.08 MB | 408 KB |
10+
| **File Count** | 38 files | 231 files | N/A | 164 files | 75 files |
1011
| **Performance** | ⚡️ Fastest | Medium | N/A | Medium | Medium |
1112
| **TypeScript** | ✅ Native | ✅ Yes | ❌ No (PHP) | ⚠️ Types available | ⚠️ Types available |
12-
| **Locales** | 20 (complete) | 70+ (partial) | 50+ | Limited | Limited |
13+
| **Locales** | 26 (complete) | 70+ (partial) | 50+ | Limited | Limited |
1314
| **Locale Coverage** | 100% | 30-80% | Varies | N/A | N/A |
1415
| **CLI Tool** | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |
1516
| **Tree Shaking** | ✅ Yes | ⚠️ Partial | N/A | ❌ No | ❌ No |
1617
| **Seeding** | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No |
1718
| **Active Development** | ✅ Yes | ✅ Yes | ✅ Yes | ⚠️ Slow | ❌ Archived |
1819

19-
## Bundle Size Comparison
20+
## Package Size Comparison
2021

21-
Smaller bundles = faster loading times and better user experience.
22+
Smaller packages = faster installation and better user experience.
23+
24+
### Published Package Size (npm download)
2225

2326
```
24-
nanofaker: ~50KB ████
25-
@faker-js/faker: ~350KB ██████████████████████████████████████
26-
Chance.js: ~100KB ████████████
27-
Casual: ~80KB ██████████
27+
nanofaker: 174KB ████
28+
Casual: 408KB ████████████
29+
@ngneat/falso: 1.16MB ████████████████████████████████████████
30+
Chance.js: 2.08MB ████████████████████████████████████████████████████████████████████
31+
@faker-js/faker: 4.29MB ████████████████████████████████████████████████████████████████████████████████████████████████████████████
2832
```
2933

30-
**Impact**: nanofaker is **7x smaller** than @faker-js/faker.
34+
**Impact**: nanofaker is **24.7x smaller** than @faker-js/faker (saves 4.12 MB, 96% reduction).
35+
36+
### File Count
37+
38+
```
39+
nanofaker: 38 files ████
40+
Casual: 75 files ████████
41+
Chance.js: 164 files ███████████████████
42+
@faker-js/faker: 231 files ████████████████████████████
43+
@ngneat/falso: 399 files ████████████████████████████████████████████████
44+
```
45+
46+
**Impact**: nanofaker has **6.1x fewer files** than @faker-js/faker.
3147

3248
### Real-World Impact
3349

34-
For a typical web application:
50+
#### Installation Time
3551

36-
```ts
37-
// Bundle size impact
38-
import { faker } from '@faker-js/faker' // +350KB
39-
import { faker } from 'nanofaker' // +50KB
52+
```bash
53+
# @faker-js/faker
54+
npm install @faker-js/faker # Downloads 4.29 MB
55+
Time: ~2-3 seconds
56+
57+
# nanofaker
58+
npm install nanofaker # Downloads 174 KB
59+
Time: ~0.3 seconds
4060

41-
// Savings: 300KB = Faster page loads!
61+
# Savings: 4.12 MB (96% reduction), ~2.5 seconds faster
4262
```
4363

64+
#### CI/CD Bandwidth
65+
66+
For projects with frequent builds:
67+
68+
```bash
69+
# 100 CI runs per day
70+
@faker-js/faker: 100 × 4.29 MB = 429 MB/day
71+
nanofaker: 100 × 174 KB = 17.4 MB/day
72+
73+
# Monthly bandwidth savings: ~12.3 GB (96% reduction)
74+
```
75+
76+
#### Development Experience
77+
78+
Smaller package means:
79+
- ✅ Faster `npm install` / `bun install`
80+
- ✅ Faster module resolution
81+
- ✅ Less disk space usage
82+
- ✅ Faster Docker image builds
83+
- ✅ Better tree-shaking potential
84+
4485
## Performance Benchmarks
4586

4687
All benchmarks run on the same machine generating 10,000 items.

eslint.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const config: ESLintConfig = stacks({
1212
yaml: true,
1313
ignores: [
1414
'fixtures/**',
15+
'packages/benchmarks/OPTIMIZATIONS.md',
1516
],
1617
})
1718

packages/benchmarks/README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,22 @@ Comprehensive benchmarks comparing nanofaker against other popular JavaScript/Ty
44

55
## Libraries Tested
66

7-
- **nanofaker** - Our performance-focused faker library
8-
- **@faker-js/faker** - The most popular faker library (successor to faker.js)
9-
- **chance** - Popular random generator
10-
- **casual** - Lightweight fake data generator
11-
- **@ngneat/falso** - TypeScript-first random data generator
7+
| Library | Version | Installed Size | Files | Performance | Notes |
8+
|---------|---------|----------------|-------|-------------|-------|
9+
| **nanofaker** | latest | 632 KB | 37 | ⚡ Fastest | 26 locales, full coverage |
10+
| **@faker-js/faker** | v10.0.0 | 4.9 MB | 231 | Medium | 70+ locales, partial coverage |
11+
| **chance** | v1.1.13 | 2.6 MB | 164 | Medium | English only |
12+
| **casual** | v1.6.2 | 584 KB | 75 | Medium | Limited locales |
13+
| **@ngneat/falso** | v7.4.0 | 2.6 MB | 399 | Medium | TypeScript-first |
14+
15+
### Key Advantages
16+
17+
**nanofaker offers:**
18+
-**Fastest performance** - 6.57x faster than @faker-js/faker
19+
-**Smallest size** - 7.8x smaller than @faker-js/faker (4.3 MB savings)
20+
-**Fewest files** - 6.2x fewer files than @faker-js/faker
21+
-**Complete locale coverage** - 100% for all 26 languages
22+
-**Modular architecture** - Install only what you need
1223

1324
## Running Benchmarks
1425

packages/benchmarks/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ async function runBenchmarks() {
258258
// nanofaker
259259
const nanoStart = performance.now()
260260
for (let i = 0; i < iterations; i++) {
261-
const user = {
261+
const _user = {
262262
name: nanofaker.person.fullName(),
263263
email: nanofaker.internet.email(),
264264
phone: nanofaker.phone.number(),
@@ -271,7 +271,7 @@ async function runBenchmarks() {
271271
// @faker-js/faker
272272
const fakerjsStart = performance.now()
273273
for (let i = 0; i < iterations; i++) {
274-
const user = {
274+
const _user = {
275275
name: fakerjs.person.fullName(),
276276
email: fakerjs.internet.email(),
277277
phone: fakerjs.phone.number(),

packages/core/build.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ await Bun.build({
44
entrypoints: ['./src/index.ts', './bin/cli.ts'],
55
outdir: './dist',
66
target: 'bun',
7+
minify: true,
8+
splitting: true,
79
plugins: [dts()],
810
})

0 commit comments

Comments
 (0)