#!/usr/bin/perl

$i = 0;
@execfile = ('mapserv35', 'mapserv36');
@gproffile = ('mapserv35.gprof', 'mapserv36.gprof');

if(`ls logfile_shp.txt` =~ /logfile/)
{
    `rm logfile_shp.txt`;
}

open(LogFile, ">logfile_shp.txt");

print LogFile $gproffile[0]."\n----------------------\n";

print LogFile "./$execfile[0] \"QUERY_STRING=map=/home/msapps/yk_demo/yk_shp.map\"\n";
$log = `./$execfile[0] "QUERY_STRING=map=/home/msapps/yk_demo/yk_shp.map" 2>&1`;

print LogFile $log;
print LogFile "mv gmon.out gmon.sum\n";
`mv gmon.out gmon35.sum`;

print LogFile $gproffile[1]."\n----------------------\n";

print LogFile "./$execfile[1] \"QUERY_STRING=map=/home/msapps/yk_demo/yk_shp.map\"\n";
$log = `./$execfile[1] "QUERY_STRING=map=/home/msapps/yk_demo/yk_shp.map" 2>&1`;

print LogFile $log;
print LogFile "mv gmon.out gmon.sum\n";
`mv gmon.out gmon36.sum`;

for($j=0; $j<14; $j++)
{
    print LogFile "./$execfile[0] \"QUERY_STRING=map=/home/msapps/yk_demo/yk_shp.map\"\n";
    $log = `./$execfile[0] "QUERY_STRING=map=/home/msapps/yk_demo/yk_shp.map" 2>&1`;

    print LogFile $log;
    print LogFile "gprof -s $execfile[0] gmon.out gmon35.sum\n";
    `gprof -s $execfile[0] gmon.out gmon35.sum\n`;

    print LogFile "./$execfile[1] \"QUERY_STRING=map=/home/msapps/yk_demo/yk_shp.map\"\n";
    $log = `./$execfile[1] "QUERY_STRING=map=/home/msapps/yk_demo/yk_shp.map" 2>&1`;

    print LogFile $log;
    print LogFile "gprof -s $execfile[1] gmon.out gmon36.sum\n";
    `gprof -s $execfile[1] gmon.out gmon36.sum\n`;
}
print LogFile "gprof $execfile[0] gmon35.sum >$gproffile[0]\n\n";
`gprof $execfile[0] gmon35.sum >$gproffile[0]`;

print LogFile "gprof $execfile[1] gmon36.sum >$gproffile[1]\n\n";
`gprof $execfile[1] gmon36.sum >$gproffile[1]`;

close LogFile;
