Read this in other languages: 简体中文 | English
With streaming write technology, precisely generate files of a specified size.
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.
-
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.
Globally install sizegen using npm:
npm install -g size-gen
Alternatively, you can use other package managers for global installation:
pnpm:
pnpm add -g size-gen
yarn:
yarn global add size-gen
Note: Please ensure that Node.js is installed.
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
.
-
Generate a 10MB file using the default chunk size:
sizegen sample.bin --size 10MB
-
Generate a 2GB file using a 1MB chunk size:
sizegen large.dat --size 2GB --chunk 1MB
You can also use abbreviated options:
- Use
-s
in place of--size
- Use
-c
in place of--chunk
For example:
sizegen data.bin -s 10MB -c 64KB
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.
This project is released under the MIT License.