cfad47cfa3/t3compiler/tads3/test/data/list_perf.t

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
/*
2
 *   list performance test
3
 */
4
5
#include "tads.h"
6
#include "t3.h"
7
8
class Throwable: object
9
    // basic exception class
10
    display = "basic exception object";
11
;
12
13
class RuntimeError: Throwable
14
    construct(errno, ...) { errno_ = errno; }
15
    errno_ = 0
16
    display = "RuntimeError: error = <<errno_>>"
17
;
18
19
_say_embed(str) { tadsSay(str); }
20
21
_main(args)
22
{
23
    t3SetSay(&_say_embed);
24
    try
25
    {
26
        main();
27
    }
28
    catch (Throwable th)
29
    {
30
        "\n\n*** Unhandled exception: << th.display >>\n";
31
    }
32
}
33
34
main()
35
{
36
    local i;
37
    local buckets = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
38
    local start;
39
40
    "Performing list indexed write operations...\n";
41
    start = getTime(GetTimeTicks);
42
    for (i = 0 ; i < 1000000 ; ++i)
43
    {
44
        local val;
45
46
        val = (i % 10) + 1;
47
        ++buckets[val];
48
    }
49
    "Elapsed time: <<getTime(GetTimeTicks) - start>>\n";
50
51
    "Number of values at each integer:\n";
52
    for (i = 1 ; i <= 10 ; ++i)
53
        " <<i>>: <<buckets[i]>>\n";
54
}
55