Cosmos/source/BaseTest/Program.cs

93 lines
No EOL
2.9 KiB
C#

using System;
using Cosmos.Compiler.Builder;
using Cosmos.Sys;
using System.Collections.Generic;
using Cosmos.Hardware;
namespace BaseTest
{
class Program
{
#region Cosmos Builder logic
// Most users wont touch this. This will call the Cosmos Build tool
[STAThread]
static void Main(string[] args)
{
BuildUI.Run();
}
#endregion
public static void Eratosthene()
{
Console.WriteLine("The sieve of Eratosthene (A little benchmark on the memoryaccess of Cosmos)");
Console.Write("Executing 4096 byte array test : ");
Int32 BeforeSeconds = RTC.GetSeconds();
Int32 BeforeMinutes = RTC.GetMinutes();
Int32 BeforeHours = RTC.GetHours();
Boolean[] arr = new Boolean[4096];
for (int i = 2; i < arr.Length; i++)
{
for (int j = i + 1; j < arr.Length; j++)
{
if (arr[j] == false)
if (j % i == 0)
arr[j] = true;
}
}
Int32 AfterSeconds = RTC.GetSeconds();
Int32 AfterMinutes = RTC.GetMinutes();
Int32 AfterHours = RTC.GetHours();
Int32 DiffsHours = (AfterHours - BeforeHours);
Int32 DiffsMinutes = (AfterMinutes - BeforeMinutes);
Int32 DiffsSeconds = (AfterSeconds - BeforeSeconds);
Int32 FinalHours = DiffsHours;
Int32 FinalMinutes = DiffsMinutes;
Int32 FinalSeconds = DiffsSeconds;
Int32 Completed = 0;
while (Completed < 3)
{
Completed = 0;
if (DiffsHours < 0)
FinalHours = 24 - DiffsHours;
else
Completed++;
if (DiffsMinutes < 0)
{
FinalMinutes = 60 - DiffsMinutes;
FinalHours--;
}
else
Completed++;
if (DiffsSeconds < 0)
{
FinalSeconds = 60 - DiffsSeconds;
FinalMinutes--;
}
else
Completed++;
}
Console.WriteLine(FinalHours + " Hours" +
FinalMinutes + " Minutes" +
FinalSeconds + " Seconds");
}
// Main entry point of the kernel
public static void Init()
{
Boot bt = new Boot();
bt.Execute();
Console.WriteLine("Welcome! This will be my playground to test out the various features i'll implement. :)");
Eratosthene();
Deboot.ShutDown();
}
}
}