The Computer Language
24.04 Benchmarks Game

simple C# aot program

source code

/* The Computer Language Benchmarks Game
   https://salsa.debian.org/benchmarksgame-team/benchmarksgame/

   line-by-line from Greg Buchholz's C program
*/


class Simple {

public static void Main(String[] args) {   
 
    int w, h, x, y, bit_num = 0;
    int byte_acc = 0;
    int i, iter = 50;
    double limit = 2.0;
    double Zr, Zi, Cr, Ci, Tr, Ti; 
    Stream stdout = Console.OpenStandardOutput();
    w = Int32.Parse(args[0]);
    h = w;    

    Console.WriteLine("P4\n{0} {1}", w, h); 
    
    for(y=0;y<h;y++) 
    {
        for(x=0;x<w;x++)
        {
            Zr = 0.0; Zi = 0.0;
            Cr = (2*(double)x/w - 1.5); Ci=(2*(double)y/h - 1);
        
            for (i=0;i<iter;i++)
            {
                Tr = Zr*Zr - Zi*Zi + Cr;
                Ti = 2*Zr*Zi + Ci;
                Zr = Tr; Zi = Ti;
                if (Zr*Zr+Zi*Zi > limit*limit)
                    break;
            }
        
            if(Zr*Zr+Zi*Zi > limit*limit) 
                byte_acc = (byte_acc << 1) | 0x00;
            else
                byte_acc = (byte_acc << 1) | 0x01;
                
            bit_num++; 

            if(bit_num == 8)
            {
                stdout.WriteByte((byte)byte_acc);
                byte_acc = 0;
                bit_num = 0;
            }
            else if(x == w-1)
            {
                byte_acc = byte_acc << (8-w%8);
                stdout.WriteByte((byte)byte_acc);
                byte_acc = 0;
                bit_num = 0;
            }
        }
    }	
}

}
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
.NET SDK 8.0.204
Host Version: 8.0.4
Commit: 2d7eea2529
<AllowUnsafeBlocks>true
<ServerGarbageCollection>true
<ConcurrentGarbageCollection>true
<PublishAot>true
<OptimizationPreference>Speed
<IlcInstructionSet>native



 Thu, 25 Apr 2024 21:58:18 GMT

MAKE:
cp simple.csharpaot Program.cs
cp Include/csharpaot/program.csproj .
mkdir obj
cp Include/csharpaot/project.assets.json ./obj
/usr/bin/dotnet publish
MSBuild version 17.9.8+b34f75857 for .NET
  Determining projects to restore...
  Restored /home/dunham/all-benchmarksgame/benchmarksgame_i53330/simple/tmp/program.csproj (in 806 ms).
  program -> /home/dunham/all-benchmarksgame/benchmarksgame_i53330/simple/tmp/bin/Release/net8.0/linux-x64/program.dll
  Generating native code
  program -> /home/dunham/all-benchmarksgame/benchmarksgame_i53330/simple/tmp/bin/Release/net8.0/linux-x64/publish/

20.29s to complete and log all make actions

COMMAND LINE:
 ./bin/Release/net8.0/linux-x64/native/program 16000

(BINARY) PROGRAM OUTPUT NOT SHOWN