Debian Codegraph @

terps/tads/tads3/test/data/list_perf.t

raw
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