Ooops think I forgot to attach it.

- Steve
#!/usr/bin/perl -w

$loops = 100;

$tmp = `cat /proc/cpuinfo | grep MHz`;
$tmp =~ /^cpu MHz\s*: (.*)/;
$cpu_speed = $1;

system("gcc ctx.c -o ctx.tmp -lpthread");
$cmd = "plot ";

for ($workers = 4; $workers < 13; $workers += 4) {
        open("WO", ">worker-diff-$workers") || die "open failed: $!";
        $cmd .= "'worker-diff-$workers' with lines, ";

        for ($size = 1; $size < 100; $size++) {

                @bar = `./ctx.tmp 2 $workers $loops $cpu_speed 4 $size 1`;

                $l = 0;
                for (@bar) {
                        if (/^%.*?([0-9.]+)/) {
                                if ($l < $1) {
                                        $l = $1;
                                }
                        }
                }

                $diff = $l;

                @bar = `./ctx.tmp 0 $workers $loops $cpu_speed 4 $size 1`;

                $l = 0;
                for (@bar) {
                        if (/^%.*?([0-9.]+)/) {
                                if ($l < $1) {
                                        $l = $1;
                                }
                        }
                }

                $diff -= $l;
                $diff /= $workers;
                print WO "$size\t$diff\n";
        }

        close(WO);
}

$cmd =~ s/,\s*$//;
print "Now run\n$cmd\nin gnuplot\n";

Reply via email to