Home > Uncategorized > Create a sparse file of a given size with Powershell

Create a sparse file of a given size with Powershell

Very simple to create a sparse file:

[System.IO.file]::writeallbytes('t.txt',$(New-Object Byte[] $(400MB)))

Creating a not-sparse file is more complicated and would likely use get-random to assign the contents of the byte. You might consider writing 1MB 400 times to get 400MB, or some derivation there of. This is why benchmarking is difficult, you need to mimic whatever operation you’re trying to benchmark. Does this operation write 1024KB chunks? Does it flush data to disk using an API other than .NET?

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: