1 // Written by Oskar Linde <oskar.lindeREM@OVEgmail.com>
2 // Found at http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=46407
3 // Sightly modified by Leandro Lucarella <llucax@gmail.com>
4 // (changed the main loop not to be endless and ported to Tango)
6 import tango.math.random.Random;
8 const IT = 5_000; // original: 50_000
11 // The real memory use, ~55 KiB (original: ~20 MiB)
13 data.length = 10_000; // original: 5_000_000
14 auto rand = new Random();
17 for (int i = 0; i < IT; ++i) {
18 // simulate reading a few kb of data (14 KiB +/- 10 KiB)
20 incoming.length = 1000 + rand.uniform!(uint) % 5000;
21 foreach (ref x; incoming)
23 // do something with the data...