Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r929 - trunk/fox/afr_demo/StandAlone


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r929 - trunk/fox/afr_demo/StandAlone
  • Date: Sat, 11 Feb 2006 14:00:07 -0700 (MST)

Author: abe
Date: Sat Feb 11 14:00:07 2006
New Revision: 929

Added:
   trunk/fox/afr_demo/StandAlone/combinestats.cpp
Modified:
   trunk/fox/afr_demo/StandAlone/CMakeLists.txt
Log:

Added combine stats program for parsing performance output from afr

A    fox/afr_demo/StandAlone/combinestats.cpp
M    fox/afr_demo/StandAlone/CMakeLists.txt


Modified: trunk/fox/afr_demo/StandAlone/CMakeLists.txt
==============================================================================
--- trunk/fox/afr_demo/StandAlone/CMakeLists.txt        (original)
+++ trunk/fox/afr_demo/StandAlone/CMakeLists.txt        Sat Feb 11 14:00:07 
2006
@@ -8,4 +8,6 @@
   ${OPENGL_LIBRARIES}                                                      
   ${X11_LIBRARIES}
   afr_shared
-)
\ No newline at end of file
+)
+
+ADD_EXECUTABLE(combinestats combinestats.cpp)
\ No newline at end of file

Added: trunk/fox/afr_demo/StandAlone/combinestats.cpp
==============================================================================
--- (empty file)
+++ trunk/fox/afr_demo/StandAlone/combinestats.cpp      Sat Feb 11 14:00:07 
2006
@@ -0,0 +1,166 @@
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+using namespace std;
+
+int main(int argc, char **argv)
+{
+  FILE **fp;
+  if(argc!=3)
+  {
+    cout << "syntax: combinestats <numfiles> <prefix> " << endl;
+    return 0;
+  }
+  int numFiles = atoi(argv[1]);
+  cout << "number of files = " << numFiles << endl;
+  fp = new FILE* [numFiles];
+  int i;
+  char fname[50];
+  for(i=0; i<numFiles; i++)
+  {
+    sprintf(fname,"%s%03d.txt", argv[2],i);
+    if((fp[i]=fopen(fname,"r"))==NULL)
+    {
+      cout << "error: cant open file for reading: " << fname << endl;
+      return 0;
+    }
+  }
+  sprintf(fname,"%s_combined.txt",argv[2]);
+  FILE *op = fopen(fname, "w");
+  cout << "opened file " << fname << " for output " << endl;
+  char ch;
+  int j;
+  for(i=0; i<numFiles; i++)
+  {
+    j = 0;
+    // first line 
+    while((ch=fgetc(fp[i]))!='\n')
+    {
+      if(i==0)
+      {
+        fprintf(op,"%c",ch);
+      }
+      j++;
+    }
+  }
+  fprintf(op,"\n");
+  
+  for(i=0; i<numFiles; i++)
+  {
+    j = 0;
+    // second line
+    while((ch=fgetc(fp[i]))!='\n')
+    {
+      if(i==0)
+      {
+        fprintf(op,"%c",ch);
+      }
+      j++;
+    }
+  }
+  fprintf(op,"\n");
+  
+  float currenttime, traceraystime, updatestatstime, adjusttilestime;
+  unsigned int tracerayscount, updatestatscount, adjusttilescount;
+  
+  currenttime = traceraystime = updatestatstime = adjusttilestime = 0.0f;
+  tracerayscount = updatestatscount = adjusttilescount = 0;
+  int tempcount;
+  float temptime;
+  // now we shall start parsing the numbers
+  for(;;)
+  {
+    // currenttime
+    currenttime = 0;
+    for(i=0; i<numFiles; i++)
+    {
+      if((fscanf(fp[i],"%f",&temptime))!=1) 
+      {
+        // check for done condition
+        cout << "done combining" << endl;
+        fclose(op);
+        return 1;
+      }
+      currenttime += temptime;
+    } 
+    currenttime /= (float)numFiles; // lets get the mean
+    
+    // tracerays time
+    traceraystime = 0;
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%f",&temptime);
+      traceraystime += temptime;
+    } 
+    //traceraystime /= (float)numFiles; // lets get the mean
+    
+    // tracerays count
+    tracerayscount = 0;
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%d",&tempcount);
+      tracerayscount += tempcount;
+    }
+    
+    // adjusttiles time
+    adjusttilestime = 0;
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%f",&temptime);
+      adjusttilestime += temptime;
+    } 
+    //adjusttilestime /= (float)numFiles; // lets get the mean
+    
+    // adjusttiles count
+    adjusttilescount = 0;
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%d",&tempcount);
+      adjusttilescount += tempcount;
+    } 
+    
+    // updatestats time
+    updatestatstime = 0;
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%f",&temptime);
+      updatestatstime += temptime;
+    } 
+    //updatestatstime /= (float)numFiles; // lets get the mean
+    
+    // updatestats count
+    updatestatscount = 0;
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%d",&tempcount);
+      updatestatscount += tempcount;
+    } 
+    
+    // skip the avg tracerays per second
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%f",&temptime);
+    }
+    
+    // skip the average updatestats per second
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%f",&temptime);
+    }
+    
+    // skip the average adjusttiles per second
+    for(i=0; i<numFiles; i++)
+    {
+      fscanf(fp[i],"%f",&temptime);
+    }
+    // output one line of stats
+    fprintf(op,"%6.2f      %6.2f   %9d      %6.2f   %9d      %6.2f   %9d     
 %9.2f   %9.2f %9.2f\n",
+    currenttime, traceraystime, tracerayscount,
+    adjusttilestime, adjusttilescount,
+    updatestatstime, updatestatscount,
+    numFiles*(float)tracerayscount/(float)traceraystime,   
+    (float)updatestatscount/(float)updatestatstime,
+    (float)adjusttilescount/(float)adjusttilestime);
+  }
+}




  • [MANTA] r929 - trunk/fox/afr_demo/StandAlone, abe, 02/11/2006

Archive powered by MHonArc 2.6.16.

Top of page