From: Oliver 'ojo' Bedford on 15 Mar 2010 05:22 Hi! For testing purposes I would like to fill chunks of memory (say 20M) with arbitrary data (say bytes with values 1,2,...255,1,...). What would be the fastest method? Oliver
From: J�rgen Exner on 15 Mar 2010 10:14 Oliver 'ojo' Bedford <newsojo(a)web.de> wrote: >For testing purposes I would like to fill chunks of memory (say 20M) with >arbitrary data (say bytes with values 1,2,...255,1,...). > >What would be the fastest method? The easiest method would probably be to define a string with say 256 bytes and then use the x operator to repeat it. I would guess it would also be quite fast because it uses perl interna only and doesn't involve a user-level loop. jue
From: bugbear on 15 Mar 2010 12:00 J�rgen Exner wrote: > Oliver 'ojo' Bedford <newsojo(a)web.de> wrote: >> For testing purposes I would like to fill chunks of memory (say 20M) with >> arbitrary data (say bytes with values 1,2,...255,1,...). >> >> What would be the fastest method? > > The easiest method would probably be to define a string with say 256 > bytes and then use the x operator to repeat it. > I would guess it would also be quite fast because it uses perl interna > only and doesn't involve a user-level loop. If speed is really important (it often isn't) you may be able to repeatedly "double up" by copying the head of the 20Meg space to itself. BugBear
From: Xho Jingleheimerschmidt on 15 Mar 2010 22:10 Oliver 'ojo' Bedford wrote: > Hi! > > For testing purposes I would like to fill chunks of memory (say 20M) with > arbitrary data (say bytes with values 1,2,...255,1,...). > > What would be the fastest method? > > Oliver Why do you need the fastest way to do it? What would happen if you used a method that was merely fast enough? You should probably fill the memory in a way that is similar to the way it would be filled in the situation you are constructing the test to test. For example, by repeated linear .=, or by repeated exponential ..=, or by x operator. Xho
From: Oliver 'ojo' Bedford on 17 Mar 2010 06:00 Am Mon, 15 Mar 2010 16:00:42 +0000 schrieb bugbear: > Jürgen Exner wrote: >> Oliver 'ojo' Bedford <newsojo(a)web.de> wrote: >>> For testing purposes I would like to fill chunks of memory (say 20M) >>> with arbitrary data (say bytes with values 1,2,...255,1,...). >>> >>> What would be the fastest method? >> >> The easiest method would probably be to define a string with say 256 >> bytes and then use the x operator to repeat it. I would guess it would >> also be quite fast because it uses perl interna only and doesn't >> involve a user-level loop. > > If speed is really important (it often isn't) you may be able to > repeatedly "double up" by copying the head of the 20Meg space to itself. Thanks for the help. I'll try both methods. Speed is not important in my case - it's just a matter of convenience (and impatience on my side). Oliver
|
Next
|
Last
Pages: 1 2 Prev: FAQ 7.8 How do I declare/create a structure? Next: check for file in $PATH |