File: stringbuild.k

package info (click to toggle)
kaya 0.4.2-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,448 kB
  • ctags: 1,694
  • sloc: cpp: 9,536; haskell: 7,461; sh: 3,013; yacc: 910; makefile: 816; perl: 90
file content (41 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
program stringbuild; // -*-C-*-ish
import memuse;
// String operations. Build lots of strings by adding stuff on in various ways.

// we need a consistent RNG for this, and ideally a fast one, since it's
// not supposed to be a test of RNG speed.
globals {
  Int randseed = 12345;
}

Int arand() {
  randseed = randseed*62089911;
  return abs(randseed>>16);
}

String buildStr {
    startstr = "Sausage machine 1 ";

    x = arand() % 50;
    for i in [0..x] {
	startstr+=Char(arand()%26+'A');
	startstr+='q';
	startstr+="foo";
    }

//    putStrLn(startstr);

    return startstr;
}


Void main()
{
    strs = createArray(10000);

    for x in [1..10000] {
	push(strs,buildStr);
    }
    putStrLn(strs[375]);
    memStat();
}