Beispiel #1
0
        public void RunSimple()
        {
            SimpleTelemetry    telemetry;
            UniversalTelemetry universal = new UniversalTelemetry();

            Random rng = new Random();

            int dummyValue;

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();

            universal.tick.Start();

            for (int i = 0; i < ITERATIONS; i++)
            {
                dummyValue = rng.Next(1000000) - rng.Next(1000000) * rng.Next(1000000);
            }

            universal.tick.Stop();

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();
            telemetry.runtime   = universal.tick.Elapsed.TotalSeconds;

            DateTime rightNow = DateTime.Now;

            try
            {
                System.IO.StreamWriter fileout = new System.IO.StreamWriter("out -sharp-.txt", true);
                //fileout.open("out.txt", fstream::app);
                fileout.WriteLine("\nSIMPLE TEST @ " + rightNow.ToString());
                fileout.WriteLine("\n\nIterations:\t" + ITERATIONS.ToString());
                fileout.WriteLine("\nRuntime (ns):\t" + telemetry.runtime.ToString());
                fileout.WriteLine("\nCPU used:\t" + telemetry.cpu_usage.ToString() + "%");
                fileout.WriteLine("\nMem used:\t" + (telemetry.mem_usage / 1000000.0).ToString() + " MB");
                fileout.Flush();
            }
            catch
            {
                Console.Write("Opening output file failed. Discarding results.\n");
            }
        }
        public void RunRecursive()
        {
            RecursiveTelemetry telemetry;
            UniversalTelemetry universal = new UniversalTelemetry();

            Random rng = new Random();

            ulong dummyValue = (ulong)rng.Next() % 10000;

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();

            universal.tick.Start();

            RecurseMng(dummyValue, DEPTH);

            universal.tick.Stop();

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();
            telemetry.runtime   = universal.tick.Elapsed.TotalSeconds;

            DateTime rightNow = DateTime.Now;

            try
            {
                System.IO.StreamWriter fileout = new System.IO.StreamWriter("out -sharp-.txt", true);
                //fileout.open("out.txt", fstream::app);
                fileout.WriteLine("\nRECURSIVE TEST @ " + rightNow.ToString());
                fileout.WriteLine("\n\nRec. depth:\t" + DEPTH.ToString());
                fileout.WriteLine("\nRuntime (ns):\t" + telemetry.runtime.ToString());
                fileout.WriteLine("\nCPU used:\t" + telemetry.cpu_usage.ToString() + "%");
                fileout.WriteLine("\nMem used:\t" + (telemetry.mem_usage / 1000000.0).ToString() + " MB");
                fileout.Flush();
            }
            catch
            {
                Console.Write("Opening output file failed. Discarding results.\n");
            }
        }
Beispiel #3
0
        public void RunCrypto()
        {
            CryptoTelemetry    telemetry;
            UniversalTelemetry universal = new UniversalTelemetry();

            chars = new char[10000];
            //bytes = new byte[10000];
            mRSA = new RSACryptoServiceProvider(KEY_SIZE);
            Random rng = new Random();

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();

            universal.tick.Start();

            Console.WriteLine("Working...");

            for (int i = 0; i < ITERATIONS; i++)
            {
                plain     = "nv805435%H^H647h6896bb^$N64nn46$N^^U4b68myb64nbg";
                recovered = "";
                if (bytes == null)
                {
                    bytes = new byte[plain.Length];
                }
                chars.Initialize();
                bytes.Initialize();
                chars = plain.ToCharArray();
                for (int j = 0; j < chars.Length; j++)
                {
                    bytes[j] = (byte)chars[j];
                }
                bytes = mRSA.Encrypt(bytes, false);
                bytes = mRSA.Decrypt(bytes, false);
                for (int j = 0; j < bytes.Length; j++)
                {
                    chars[j] = (char)bytes[j];
                }
                foreach (var c in chars)
                {
                    recovered += c;
                }
                if (recovered != plain)
                {
                    throw new CryptographicException("ERROR: Decrypted data does not match original.\n");
                }
            }

            universal.tick.Stop();

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();
            telemetry.runtime   = universal.tick.Elapsed.TotalSeconds;

            DateTime rightNow = DateTime.Now;

            try
            {
                System.IO.StreamWriter fileout = new System.IO.StreamWriter("out -sharp-.txt", true);
                //fileout.open("out.txt", fstream::app);
                fileout.WriteLine("\nCRYPTO TEST @ " + rightNow.ToString());
                fileout.WriteLine("\n\nIterations:\t" + ITERATIONS.ToString());
                fileout.WriteLine("\nKey size:\t" + KEY_SIZE.ToString());
                fileout.WriteLine("\nRuntime (ns):\t" + telemetry.runtime.ToString());
                fileout.WriteLine("\nCPU used:\t" + telemetry.cpu_usage.ToString() + "%");
                fileout.WriteLine("\nMem used:\t" + (telemetry.mem_usage / 1000000.0).ToString() + " MB");
                fileout.Flush();
            }
            catch
            {
                Console.Write("Opening output file failed. Discarding results.\n");
            }
        }
Beispiel #4
0
        public void RunArrays()
        {
            ArraysTelemetry    telemetry;
            UniversalTelemetry universal = new UniversalTelemetry();

            double dummyValue;

            Random rng = new Random();

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();

            universal.tick.Start();

            Console.WriteLine("Populating array...");

            for (int i = 0; i < ARR_SIZE; i++)
            {
                for (int j = 0; j < ARR_SIZE; j++)
                {
                    for (int k = 0; k < ARR_SIZE; k++)
                    {
                        dummyValue = ((rng.Next() % 999999) - (rng.Next() % 999999)) * (rng.Next() / 999999.9);
                        bigList[i][j].Add(dummyValue);
                    }
                }
            }

            universal.tick.Stop();
            telemetry.time_to_fill = universal.tick.Elapsed.TotalSeconds;
            universal.tick.Reset(); universal.tick.Start();

            Console.WriteLine("Inserting to array...");

            for (int i = 0; i < ARR_SIZE; i++)
            {
                for (int j = 0; j < ARR_SIZE; j++)
                {
                    for (int k = 0; k < ARR_SIZE; k++)
                    {
                        dummyValue = ((rng.Next() % 999999) - (rng.Next() % 999999)) * (rng.Next() / 999999.9);
                        bigList[i][j].Insert(bigList.Count / 2, dummyValue);
                    }
                }
            }

            universal.tick.Stop();
            telemetry.time_to_insert = universal.tick.Elapsed.TotalSeconds;
            universal.tick.Reset(); universal.tick.Start();

            Console.WriteLine("Inserting to array...");

            for (int i = 0; i < ARR_SIZE; i++)
            {
                for (int j = 0; j < ARR_SIZE; j++)
                {
                    bigList[i][j].Clear();
                }
            }

            universal.tick.Stop();
            telemetry.total_runtime = universal.tick.Elapsed.TotalSeconds + telemetry.time_to_fill + telemetry.time_to_insert;

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();

            DateTime rightNow = DateTime.Now;

            try
            {
                System.IO.StreamWriter fileout = new System.IO.StreamWriter("out -sharp-.txt", true);
                //fileout.open("out.txt", fstream::app);
                fileout.WriteLine("\nARRAYS TEST @ " + rightNow.ToString());
                fileout.WriteLine("\n\nDim. size:\t" + ARR_SIZE.ToString());
                fileout.WriteLine("\nFill time (ns):\t" + telemetry.time_to_fill.ToString());
                fileout.WriteLine("\nInsert time (ns):\t" + telemetry.time_to_insert.ToString());
                fileout.WriteLine("\nTotal Runtime (ns):\t" + telemetry.total_runtime.ToString());
                fileout.WriteLine("\nCPU used:\t" + telemetry.cpu_usage.ToString() + "%");
                fileout.WriteLine("\nMem used:\t" + (telemetry.mem_usage / 1000000.0).ToString() + " MB");
                fileout.Flush();
            }
            catch
            {
                Console.Write("Opening output file failed. Discarding results.\n");
            }
        }
Beispiel #5
0
        public void RunComplex()
        {
            ComplexTelemetry   telemetry;
            UniversalTelemetry universal = new UniversalTelemetry();

            double val;

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();

            universal.tick.Start();

            for (int i = 0; i < ITERATIONS; i++)
            {
                Math.Cos(decirand());
                Math.Sin(decirand());
                Math.Tan(decirand());
                Math.Acos(decirand());
                Math.Asin(decirand());
                Math.Atan(decirand());
                Math.Atan2(decirand(), decirand());
                Math.Cosh(decirand());
                Math.Sinh(decirand());
                Math.Tanh(decirand());
                Math.Exp(decirand());
                Math.Log(decirand());
                Math.Log10(decirand());
                Math.Pow(2, decirand());
                Math.Pow(decirand(), rng.Next());
                Math.Sqrt(decirand());
                Math.Pow(decirand(), 1.0 / 3);
                Math.Sqrt(Math.Pow(decirand(), 2) + Math.Pow(decirand(), 2));
                //Math.Erf(decirand());
                //erfc(decirand());
                stat.DataManipulator.Statistics.GammaFunction(decirand());
                Math.Log10(Math.Abs(stat.DataManipulator.Statistics.GammaFunction(decirand())));
                Math.Round(decirand());
                Math.Abs(decirand() * -1);
                val = (decirand() * decirand()) + decirand();
            }

            universal.tick.Stop();

            telemetry.mem_usage = universal.ramCounter.NextValue();
            telemetry.cpu_usage = universal.cpuCounter.NextValue();
            telemetry.runtime   = universal.tick.Elapsed.TotalSeconds;

            DateTime rightNow = DateTime.Now;

            try
            {
                System.IO.StreamWriter fileout = new System.IO.StreamWriter("out -sharp-.txt", true);
                //fileout.open("out.txt", fstream::app);
                fileout.WriteLine("\nCOMPLEX TEST @ " + rightNow.ToString());
                fileout.WriteLine("\n\nIterations:\t" + ITERATIONS.ToString());
                fileout.WriteLine("\nRuntime (ns):\t" + telemetry.runtime.ToString());
                fileout.WriteLine("\nCPU used:\t" + telemetry.cpu_usage.ToString() + "%");
                fileout.WriteLine("\nMem used:\t" + (telemetry.mem_usage / 1000000.0).ToString() + " MB");
                fileout.Flush();
            }
            catch
            {
                Console.Write("Opening output file failed. Discarding results.\n");
            }
        }