~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to tads/tads3/test/data/rand_perf_arr.t

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Beucler
  • Date: 2009-09-11 20:09:43 UTC
  • Revision ID: james.westby@ubuntu.com-20090911200943-idgzoyupq6650zpn
Tags: upstream-2009-08-25
ImportĀ upstreamĀ versionĀ 2009-08-25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   random number generator - performance test
 
3
 */
 
4
 
 
5
#include "tads.h"
 
6
#include "t3.h"
 
7
#include "vector.h"
 
8
 
 
9
preinit()
 
10
{
 
11
}
 
12
 
 
13
main(args)
 
14
{
 
15
    local i;
 
16
    local buckets;
 
17
    local start;
 
18
 
 
19
    buckets = new Vector(10);
 
20
    buckets.fillValue(0, 1, 10);
 
21
    
 
22
    randomize();
 
23
 
 
24
    "Generating random numbers from 1 to 10...\n";
 
25
    start = getTime(GetTimeTicks);
 
26
    for (i = 0 ; i < 1000000 ; ++i)
 
27
    {
 
28
        local val;
 
29
 
 
30
        val = rand(10) + 1;
 
31
        ++buckets[val];
 
32
    }
 
33
    "Elapsed time: <<getTime(GetTimeTicks) - start>>\n";
 
34
 
 
35
    "Number of values at each integer:\n";
 
36
    for (i = 1 ; i <= 10 ; ++i)
 
37
        " <<i>>: <<buckets[i]>>\n";
 
38
}
 
39