View mode: basic / threaded / horizontal-split · Log in · Help
May 20, 2005
Shootout analyzer
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
Re: Shootout analyzer
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);
>
> }
>
Top | Discussion index | About this forum | D home