size-gen
v1.0.1
Published
A Node.js CLI utility to generate files of exact byte sizes efficiently via stream-chunked writing, perfect for testing, benchmarking, or disk space simulations.
Downloads
6
Readme
sizegen
Read this in other languages: 简体中文 | English
With streaming write technology, precisely generate files of a specified size.
Project Overview
sizegen is a command-line tool that uses streaming chunk writing to generate files of fixed sizes. It is ideal for disk testing, performance benchmarking, and generating sample data. The streaming method ensures that even large files can be generated efficiently while significantly reducing memory usage.
Key Features
Efficient Streaming Generation
Generates large files efficiently using chunked writing, ensuring minimal memory usage.Customizable Chunk Size
Allows users to specify the size of the chunks used during writing based on their requirements.
Installation
Globally install sizegen using npm:
npm install -g size-genAlternatively, you can use other package managers for global installation:
pnpm:
pnpm add -g size-genyarn:
yarn global add size-genNote: Please ensure that Node.js is installed.
Usage
The basic command format for running sizegen is as follows:
sizegen <output> --size <size> [--chunk <chunk>]Where:
<output>: The output file name (must include a file extension, e.g.,data.bin).--size <size>: Specifies the target file size with a unit (e.g.,10B,512KB,2MB, or3.5GB).--chunk <chunk>: (Optional) Specifies the chunk size used for writing, such as16KB,1MB, or4MB. The default is64KB.
Examples
Generate a 10MB file using the default chunk size:
sizegen sample.bin --size 10MBGenerate a 2GB file using a 1MB chunk size:
sizegen large.dat --size 2GB --chunk 1MB
Shortcuts
You can also use abbreviated options:
- Use
-sin place of--size - Use
-cin place of--chunk
For example:
sizegen data.bin -s 10MB -c 64KBContributing and Feedback
We welcome contributions, bug reports, and feature suggestions! Before submitting an issue, please check the Issues page to see if similar feedback has already been provided.
License
This project is released under the MIT License.
