I wish create a large random file (for testing copy in powershell
between servers on WAN) i'm using a get-random function but it's very
slow. A file can have a size of 1-5 Gb
Do you have ideas for accelerate this program?
Thanks and happy new year.
My tiny program
function GenChaine([int]$n)
# G�n�ration d'une chaine al�atoire de n caract�res
{
$caracteres = "a|z|e|r|t|y|u|i|o|p|q|s|d|f|g|h|j|k|l|m|w|x|c|v|b|n"
$caracteres += "A|Z|E|R|T|Y|U|I|O|P|Q|S|D|F|G|H|J|K|L|M|W|X|C|V|B|N"
$caracteres += "0|1|2|3|4|5|6|7|8|9"
$chaine = ""
$liste = $caracteres.split("|")
for ($i=1;$i -le $n;$i++)
{
#$chaine += ( $liste | Get-Random)
$chaine += "A"
}
return $chaine
}
$blocs = (1024*1024*3)
if ( Test-Path -Path $Nomfichier ) {Remove-Item -Path $NomFichier
-Force}
for ($i=1; $i -le $blocs; $i++)
{
$a = GenChaine(1022)
Add-Content -Path $NomFichier -Value $a
}
Marco
"N4p0l&0n" <n...@po.auz> wrote in message
news:OsbAYaLj...@TK2MSFTNGP02.phx.gbl...
Le 03/01/2010 22:00, Marco Shaw [MVP] a �crit :
"Write all at once (allocates 1mb buffer) ...
set-content -value (new-object byte[] 1mb) -encoding byte out.dat
or 1kb block at a time
1..1024 | % { ,(new-object byte[] 1kb) } | set-content -encoding byte
out.dat
Note the ,(...) - this is so the blocks are written as a unit instead of 1
byte at a time..."
"N4p0l&0n" <n...@po.auz> wrote in message
news:#cfj3fMj...@TK2MSFTNGP04.phx.gbl...
>>> I wish create a large random file (for testing copy in powershell
>>> between servers on WAN) i'm using a get-random function but it's very
>>> slow. A file can have a size of 1-5 Gb
[snip code fragment]
>> Do the contents have to be randomized also or can it be anything? Are
>> you using PowerShell v1 or v2?
> Randomized too and i'm using pws V2. Idealy files would be binary
My immediate reaction is that POSH (or any other scripting language) isn't a
good choice for generating huge files like that. As you've found the
overhead is quite non-trivial; that's not an issue for something like
generating a temporary folder name or selecting ten userids to receive a
user satisfaction survey, but for multiple gigabyte-sized files it's a
showstopper.
There are commercial data generators you could buy (no, I can't recommend
one since the last time I needed one was on IBM mainframes 20+ years ago --
anyone else here remember IEBDG?) but for what sounds like a one-time use
it shouldn't take too long to write one in the compiled language of your
choice...or to find one via Google.
Joe Morris
Martin
"Joe Morris" <j.c.m...@verizon.net> wrote in message
news:hhrid...@news4.newsguy.com...
Great ! Thanks for the syntax.
Le 04/01/2010 02:26, Marco Shaw [MVP] a �crit :
It's for testing appliance compression between sites (appliances
Riverbade, expand, ipanema, ...) ...
Le 04/01/2010 22:12, Martin Zugec a �crit :
Le 05/01/2010 22:38, Robert Robelo a �crit :