summaryrefslogtreecommitdiff
path: root/performance-tests/Synch-Benchmarks/run_tests.pl
blob: 92bc3b787fd61d19ca79391085232ae605a06e5e (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$

$EXE = "synch_driver";
$Win32 = 0;
if ($^O eq "MSWin32")
{
    $Win32 = 1;
}

$debug = 0;
$name = "release";
$result_dir = "results";
$svcconf_dir = "svcconf";
$conf_ext = ".conf";

@Null_List = ();

# This is called "baseline"
@Baseline_List = ("base_acquire",
                  "base_tryacquire",
                  "base_acquire_read",
                  "base_tryacquire_read",
                  "base_acquire_write",
                  "base_tryacquire_write");

# this is called "perf_thrno"
@Perf_Thr_Number_List = ("perf_t1",
                         "perf_t2",
                         "perf_t4",
                         "perf_t8",
                         "perf_t16",
                         "perf_t32",
                         "perf_t64");

@Target = @Null_List;

while ( $#ARGV >= 0  &&  $ARGV[0] =~ /^-/ )
{
    if ($ARGV[0] eq '-d')       # Run debug mode
    {
        $name = "debug";
    }
    elsif ($ARGV[0] eq '-p')    # Debug perl script
    {
        $debug = 1;
        print "debug perl scirpt\n";
    }
    elsif ($ARGV[0] eq '-D')    # Subdir name to put the result
    {
        shift;
        $result_dir = $ARGV[0];
    }
    elsif ($ARGV[0] eq '-S')    # Subdir to svc.conf files.
    {
        shift;
        $svcconf_dir = $ARGV[0];
    }
    elsif ($ARGV[0] eq '-N')    # Specify test name.
    {
        shift;
        if ($ARGV[0] eq "baseline")
        {
            @Target = @Baseline_List;
        }
        elsif ($ARGV[0] eq "perf_thrno")
        {
            @Target = @Perf_Thr_Number_List;
        }
        else
        {
            die "Unknown test \"$ARGV[0]\"\n";
        }
    }
    else
    {
        warn "$0:  unknown option $ARGV[0]\n";
        die $usage;
    }
    shift;
}

die "You must specify a test to run\n" if (scalar (@Target) == 0);

if ($Win32 != 0)
{
    $execname = "$name\\$EXE";
    $DIR_SEPARATOR = '\\';
}
else
{
    $execname = "./$EXE";       # Notice that on UNIX, you much build
                                # Debug/Release program explicitly
                                # before running the script.
    $DIR_SEPARATOR = '/';
}

for ($Cntr = 0; $Cntr < scalar (@Target); $Cntr++)
{
    $Redirect_Output = "$result_dir$DIR_SEPARATOR$Target[$Cntr].$name";
    if ($debug != 0)             # Only redirect output in actual run
    {
        print "Redirecting output to $Redirect_Output\n";
    }
    else
    {
        open STDOUT, "> $Redirect_Output";
        open STDERR, ">&STDOUT";
    }

    @args = ("$execname",
             "-f",
             "$svcconf_dir$DIR_SEPARATOR$Target[$Cntr]$conf_ext");

    if ($debug != 0)
    {
        print "Debug mode: Executing -- ";
        for ($args_c = 0; $args_c < scalar (@args); $args_c ++)
        {
            print "$args[$args_c] ";
        }
        print "\n";
    }
    else
    {
        system (@args);
    }
}