nv-random-dir
v1.0.0
Published
A tool for generating realistic random directory structures to benchmark and test filesystem performance.
Readme
Random Filesystem Generator
A tool for generating realistic random directory structures to benchmark and test filesystem performance.
Purpose
This tool creates random directory trees with realistic Linux-style naming patterns and diverse file types. It's designed primarily for filesystem performance testing - allowing you to quickly generate large, complex directory structures to measure:
- Directory traversal speed
- File creation/deletion performance
- Metadata operations
- Search and indexing efficiency
- Backup/sync tool performance
- Filesystem driver benchmarks
Installation
npm install nv-random-dirUsage
const rand_mkdir = require('nv-random-dir');
// Generate a random directory tree
const path = rand_mkdir('./workspace');
console.log(`Test filesystem created at: ${path}`);
// => Test filesystem created at: ./workspace/rand_dir1709251234567890123Features
- Realistic Structure: Generates directory trees based on real Linux filesystem patterns
- Diverse File Types: Creates files with 100+ common extensions (.js, .py, .jpg, .mp4, .zip, etc.)
- Unique Names: Uses Linux-style naming (tmp, usr-local, lib-cfg, var-log, etc.)
- Variable Depth: Random tree depth and branching for realistic complexity
- Fast Generation: Creates complex structures in milliseconds
Example Output
workspace/rand_dir1709251234567890/
├── tmp-cache/
│ ├── app.js
│ ├── data.json
│ └── image.png
├── usr-local/
│ ├── bin/
│ │ ├── main.cpp
│ │ └── utils.h
│ └── lib-pkg/
│ ├── module.so
│ └── config.yml
└── var-log/
├── error.log
└── debug.txtAPI
rand_mkdir(workdir = './')
Creates a random directory structure in the specified working directory.
Parameters:
workdir(string): Base directory where the random tree will be created. Defaults to'./'
Returns:
- (string): Full path to the created root directory
Throws:
- Error if
workdirdoesn't exist
Example:
try {
const testDir = rand_mkdir('/tmp');
console.log(`Created test structure: ${testDir}`);
// Run your filesystem benchmarks here...
} catch (error) {
console.error('Failed to create structure:', error.message);
}File Extensions Supported
The generator includes 100+ file extensions across multiple categories:
- Programming:
.js,.ts,.py,.go,.rs,.java,.cpp,.c - Web:
.html,.css,.scss,.vue,.jsx,.svg - Images:
.jpg,.png,.gif,.webp,.ico,.psd - Video:
.mp4,.avi,.mkv,.mov,.webm - Audio:
.mp3,.wav,.flac,.aac,.ogg - Archives:
.zip,.tar,.gz,.7z,.rar - Documents:
.txt,.md,.pdf,.doc,.csv - Config:
.yml,.json,.toml,.env,.xml - Databases:
.db,.sqlite,.sql
Use Cases
Filesystem Performance Testing
const rand_mkdir = require('nv-random-dir');
const { performance } = require('perf_hooks');
// Create test structure
const testDir = rand_mkdir('./benchmark');
// Test directory traversal speed
const start = performance.now();
// ... your filesystem operations ...
const end = performance.now();
console.log(`Operation took ${end - start}ms`);Benchmarking Examples
- Directory walking: Test recursive directory traversal algorithms
- Search operations: Measure file search and filtering performance
- Bulk operations: Test mass file creation, copy, move, or delete
- Indexing: Benchmark file indexing and metadata extraction
- Compression: Test archiving tools on diverse file structures
- Sync tools: Measure rsync, rclone, or backup tool performance
License
ANY
