Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r597 - branches/itanium2/StandAlone


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r597 - branches/itanium2/StandAlone
  • Date: Wed, 5 Oct 2005 19:31:23 -0600 (MDT)

Author: abe
Date: Wed Oct  5 19:31:23 2005
New Revision: 597

Added:
   branches/itanium2/StandAlone/manta_path_plot.pl
Log:


Added perl script to run manta command lines from an input file (one command 
per line) on a camera path and then gnuplot the results.

Produces a web page, see: 
http://www.sci.utah.edu/~abe/manta_doc/cockpit-np/cockpit-np.html ;(someone 
else was trying to use the system.)

A    StandAlone/manta_path_plot.pl



Added: branches/itanium2/StandAlone/manta_path_plot.pl
==============================================================================
--- (empty file)
+++ branches/itanium2/StandAlone/manta_path_plot.pl     Wed Oct  5 19:31:23 
2005
@@ -0,0 +1,244 @@
+#!/usr/bin/perl
+
+# This script runs the manta command read from each line of the input text 
file
+# with the specified camera path and creates a gnuplot of the results.
+# An html page is generated with all of the gnuplot images.
+
+# Abe Stephens, October 2005
+
+# Parse args.
+$input_file    = "";
+$output_prefix = "manta_path_plot";
+
+$path_file     = "";
+$path_sync     = 1;
+$path_t        = 0; # Use default.
+$path_time     = 0;
+$path_start    = 0;
+$path_last     = 0;
+$path_warmup   = 10;
+$title         = "Manta Camera Path Benchmark";
+
+for ($i=0;$i<@ARGV;++$i) {
+    if ($ARGV[$i] eq "-file") {
+        $input_file = $ARGV[++$i];
+    }
+    elsif ($ARGV[$i] eq "-prefix") {
+        $output_prefix = $ARGV[++$i];
+    }
+    elsif ($ARGV[$i] eq "-path") {
+        $path_file = $ARGV[++$i];
+    }
+    elsif ($ARGV[$i] eq "-sync") {
+        $path_sync = $ARGV[++$i];
+    }
+    elsif ($ARGV[$i] eq "-delta_t") {
+        $path_t = $ARGV[++$i];
+    }
+    elsif ($ARGV[$i] eq "-delta_time") {
+        $path_time = $ARGV[++$i];
+    }
+    elsif ($ARGV[$i] eq "-interval") {
+        $path_start = $ARGV[++$i];
+        $path_last  = $ARGV[++$i];
+    }
+    elsif ($ARGV[$i] eq "-warmup") {
+        $path_warmup = $ARGV[++$i];
+    }
+    elsif ($ARGV[$i] eq "-title") {
+        $title = $ARGV[++$i];
+    }
+}
+
+# Check to see if any defaults should be used.
+if (($path_file eq "") || ($input_file eq "")) {
+    print "Usage: \n";
+    print "-file       <manta commands file>\n";
+    print "-prefix     <output png prefix>\n";
+    print "-path       <camera path file>\n";
+    print "-sync       <camera path sync>\n";
+    print "-delta_t    <camera path delta t>\n";
+    print "-delta_time <camera path delta time>\n";
+    print "-interval   <m> <n>\n";
+    print "-warmup     <n>\n";
+    print "-title      <title>\n";
+
+    exit(1);
+}
+
+# Open the input file.
+if (!open( INPUT, "<" , $input_file) ) {
+    print "Could not open input file " . $input_file . "\n";
+    exit(1);
+}
+
+# Output the output html file.
+$output_html = $output_prefix . ".html";
+if (!open( HTML, ">", $output_html )) {
+    print "Could not open output html file " . $output_html . "\n";
+    exit(1);
+}
+
+print HTML "<head title=\"$title\"></head>\n";
+print HTML "<h1>$title</h1>\n";
+print HTML "Generated using:<br><font face=\"courier\" 
size=-1>manta_path_plot.pl " . join(" ",@ARGV) . "</font><p>\n";
+
+# Form the camera path command.
+$path_command = " -ui \"camerapath( -file $path_file -sync $path_sync 
-behavior exit -warmup $path_warmup ";
+if ($path_t != 0) {
+    $path_command = $path_command . "-delta_t $path_t ";
+}
+if ($path_time != 0) {
+    $path_command = $path_command . "-delta_time $path_time ";
+}
+if ($path_start != 0) {
+    $path_command = $path_command . "-interval $path_start $path_last ";
+}
+
+$path_command = $path_command . ")\"";
+
+# Read in manta commands.
+$line = 0;
+
+while (<INPUT>) {
+
+    $min_fps = 999;
+    $max_fps = 0;
+    $total_fps = 0;
+    $total_samples = 0;
+
+    $out_file = $output_prefix . $line . ".temp";
+
+    chomp($_);
+    $command  = $_ . $path_command; #  . ">& /dev/null";
+
+    # Open a temporary output file.
+    if (!open( TEMP, ">", $out_file )) {
+        print "Could not open temp out file: $out_file\n";
+        exit(1);
+    }
+
+    # Open a pipe to manta.
+    if (!open( MANTA, "-|", $command )) {
+        print "Could not execute line $line: $command\n";
+        exit(1);
+    }
+
+    push(@command_array, $command);
+
+    # Wait for input
+    while (<MANTA>) {
+        chomp;
+        @column = split(/ /);
+
+        # print ("Frame: $column[0] fps: $column[4]\n");
+        print TEMP $column[0] . " " . $column[4] . "\n";
+
+        # Keep track of min and max.
+        if ($column[4] < $min_fps) {
+            $min_fps = $column[4];
+        }
+        if ($column[4] > $max_fps) {
+            $max_fps = $column[4];
+        }
+        
+        # Keep track of average.
+        $total_fps = $total_fps + $column[4];
+        $total_samples++;
+    }
+
+    # Close the file handles.
+    close(MANTA);
+    close(TEMP);
+
+    # Pipe commands to gnuplot.
+    if (!open(GNUPLOT, "|-", "gnuplot")) {
+        print "Could not open gnuplot\n";
+        exit(1);
+    }
+
+    $png_file = $output_prefix . $line . ".png";
+    
+    print GNUPLOT "set data style linespoints\n";
+    print GNUPLOT "set term png small color\n";
+    print GNUPLOT "set xlabel \"Frame Number\"\n";
+    print GNUPLOT "set ylabel \"fps\"\n";
+    print GNUPLOT "set title \"$input_file command $line\"\n";
+    print GNUPLOT "set output \"$png_file\"\n";
+    print GNUPLOT "plot \"$out_file\" using 1:2 title \"fps\"\n";
+    
+    close(GNUPLOT);
+
+    # Output to html file.
+    print HTML "<h2>\"$input_file\" command line $line</h2>\n";
+    print HTML "<font face=\"courier\" size=-1>$command</font><br>\n";
+    print HTML "<img src=\"$png_file\" /><br><pre>\n";
+    print HTML "Min  fps: $min_fps\n";
+    print HTML "Max  fps: $max_fps\n";
+    print HTML "Mean fps: " . (($min_fps+$max_fps)/2) . "\n";
+    print HTML "Avg  fps: " . ($total_fps / $total_samples) . "</pre>\n";
+    print HTML "<hr width=100%><p>\n";
+
+    push(@out_array,$out_file);
+
+    ++$line;
+}
+
+
+
+# Create a graph with all results.
+# Pipe commands to gnuplot.
+
+print HTML "<h2>Summary</h2>\n";
+print HTML "<pre>\n";
+
+if (!open(GNUPLOT, "|-", "gnuplot")) {
+    print "Could not open gnuplot\n";
+    exit(1);
+}
+
+$png_file = $output_prefix . "-all.png";
+
+$plot = "plot ";
+for ($i=0; $i<@out_array; ++$i) {
+
+    print HTML "Line $i: $command_array[$i]\n";
+
+    $plot = $plot . "\"$out_array[$i]\" using 1:2 title \"Line: $i\" ";
+    if ($i < (@out_array)-1) {
+        $plot = $plot . ", ";
+    }
+}
+$plot = $plot . "\n";
+
+print HTML "</pre>\n";
+
+print GNUPLOT "set data style linespoints\n";
+print GNUPLOT "set term png small color\n";
+print GNUPLOT "set xlabel \"Frame Number\"\n";
+print GNUPLOT "set ylabel \"fps\"\n";
+print GNUPLOT "set title \"$input_file Summary\"\n";
+print GNUPLOT "set output \"$png_file\"\n";
+print GNUPLOT $plot;
+    
+close(GNUPLOT);
+
+# Output to html file.
+print HTML "<img src=\"$png_file\" /><br><pre>\n";
+print HTML "<hr width=100%><p>\n";
+
+close (HTML);
+close (INPUT);
+
+# Delete the temp file.
+for ($i=0; $i<@out_array; ++$i) {
+    if (!unlink($out_array[$i])) {
+        print "Could not delete $out_file\n";
+        exit(1);
+    }
+}
+
+
+
+
+




  • [MANTA] r597 - branches/itanium2/StandAlone, abe, 10/05/2005

Archive powered by MHonArc 2.6.16.

Top of page