www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Shootout analyzer

reply =?iso-8859-1?q?Knud_S=F8rensen?= <12tkvvb02 sneakemail.com> writes:
I wrote a small program to help analyze the shootout result on   
http://shootout.alioth.debian.org/download/ndata.csv
to help find d's weak spots.




Here it is:

/* Shootout  analyzer
   analyze the data files from
   http://shootout.alioth.debian.org/download/ndata.csv
   By Knud Soerensen (20 May 2005)
*/

import std.stream,std.string,std.format;

void main() {
   float[6][char[]]  data;
   char[] line,index,bufr = new char[128];
   char[][] word;

   BufferedFile ndata=new BufferedFile("ndata.csv");
   line=ndata.readLine(bufr);

   while(!ndata.eof) {
      line=ndata.readLine(bufr);
      word=split(line,",");
      index=word[0]~"("~word[3]~")";
      for(int i=0;i<3;i++)
        if (atof(word[6])>0.0)
        {
         float tmp=atof(word[5+i]);

         if (word[1].cmp("dlang")==0) data[index][3+i]=tmp;
         else if (tmp>0 && (data[index][i]==0.0 || (tmp<data[index][i])))
data[\index][i]=tmp;
       }
   }
   ndata.close();

   char[][] secs,kb,lines;

     foreach(char[] id; data.keys){
        secs.length=secs.length+1;
        secs[length-1]=(data[id][3]!=0.0f ?
format("%1.5f",data[id][0]/data[id]\[3]) : "!error")~" "~id;

	kb.length=kb.length+1;
	kb[length-1]=(data[id][4]!=0.0f ? format("%1.5f",data[id][1]/data[id][4\]) :
"!error")~" "~id;

	lines.length=lines.length+1;
	lines[length-1]=(data[id][5]!=0.0f ? format("%1.5f",data[id][2]/data[id\][5])
: "!error")~" "~id;


//       printf("%.*s : %f/%f %f/%f %f/%f
\n",id,data[id][0],data[id][3],data[i\d][1],data[id][4],data[id][2],data[id][5]);

  }
  printf("**********  time  **********\n");
  foreach(char[] val; secs.sort) printf("%.*s \n",val);

  printf("\n**********  memory  **********\n");
  foreach(char[] val; kb.sort) printf("%.*s \n",val);

  printf("\n**********  lines  **********\n");
  foreach(char[] val; lines.sort) printf("%.*s \n",val);

}
May 20 2005
parent "Charlie" <charles jwavro.com> writes:
Here are the output results for the lazy ( like me ).

"Knud Sørensen" <12tkvvb02 sneakemail.com> wrote in message
news:pan.2005.05.20.19.51.30.336192 sneakemail.com...
 I wrote a small program to help analyze the shootout result on
 http://shootout.alioth.debian.org/download/ndata.csv
 to help find d's weak spots.




 Here it is:

 /* Shootout  analyzer
    analyze the data files from
    http://shootout.alioth.debian.org/download/ndata.csv
    By Knud Soerensen (20 May 2005)
 */

 import std.stream,std.string,std.format;

 void main() {
    float[6][char[]]  data;
    char[] line,index,bufr = new char[128];
    char[][] word;

    BufferedFile ndata=new BufferedFile("ndata.csv");
    line=ndata.readLine(bufr);

    while(!ndata.eof) {
       line=ndata.readLine(bufr);
       word=split(line,",");
       index=word[0]~"("~word[3]~")";
       for(int i=0;i<3;i++)
         if (atof(word[6])>0.0)
         {
          float tmp=atof(word[5+i]);

          if (word[1].cmp("dlang")==0) data[index][3+i]=tmp;
          else if (tmp>0 && (data[index][i]==0.0 || (tmp<data[index][i])))
data[\index][i]=tmp;
        }
    }
    ndata.close();

    char[][] secs,kb,lines;

      foreach(char[] id; data.keys){
         secs.length=secs.length+1;
         secs[length-1]=(data[id][3]!=0.0f ?
format("%1.5f",data[id][0]/data[id]\[3]) : "!error")~" "~id;
 kb.length=kb.length+1;
 kb[length-1]=(data[id][4]!=0.0f ? format("%1.5f",data[id][1]/data[id][4\])
: "!error")~" "~id;
 lines.length=lines.length+1;
 lines[length-1]=(data[id][5]!=0.0f ?
format("%1.5f",data[id][2]/data[id\][5]) : "!error")~" "~id;
 //       printf("%.*s : %f/%f %f/%f %f/%f
\n",id,data[id][0],data[id][3],data[i\d][1],data[id][4],data[id][2],data[id] [5]);
   }
   printf("**********  time  **********\n");
   foreach(char[] val; secs.sort) printf("%.*s \n",val);

   printf("\n**********  memory  **********\n");
   foreach(char[] val; kb.sort) printf("%.*s \n",val);

   printf("\n**********  lines  **********\n");
   foreach(char[] val; lines.sort) printf("%.*s \n",val);

 }
begin 666 output.txt M*BHJ*BHJ*BHJ*B =&EM92 *BHJ*BHJ*BHJ* T*(65R<F]R(&9A;FYK=6-H M<G)O<B!H96%L=& H-C P*2 -"B%E<G)O<B!H96QL;R Q*2 -"B%E<G)O<B!I M"B%E<G)O<B!L:7-T<R T*2 -"B%E<G)O<B!M871R:7 H,3 I( T*(65R<F]R M,CD =V]R9&9R97$H,C4I( T*,"XW,30R.2!W;W)D9G)E<2 U*2 -"C N-S(W M( T*,"XY,#DP.2 M('-I979E*#DP M,C<Y-C8 =V]R9&9R97$H,C I( T*,"XR.#DX M>&UA=&-H*#DP M.#DV M,3 Q."!N<VEE=F5B:71S*#DI ` end
May 20 2005