Exemplo n.º 1
0
        private void TimeComplexity_Click(object sender, EventArgs e)
        {
            Stopwatch stopwatch = Stopwatch.StartNew(); //creates and start the instance of Stopwatch

//your sample code
            k.CompileCSharp(t, "Sample.exe");

            stopwatch.Stop();
            s = stopwatch.ElapsedMilliseconds;
            MessageBox.Show("\n  The Time Complexity for the given program is:" + s + " MilliSeconds");

//LinesOfCode.Enabled = true;
        }
        private void Compile()
        {
            k.RefAssemblies.Clear();

            Assembly s  = Assembly.LoadFile(@"C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll");
            Assembly s1 = Assembly.LoadFile(@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll");

            k.RefAssemblies.Add(s);
            k.RefAssemblies.Add(s1);
            var AssembliesList = ManiPulateMainClass.GetAssemblyNames(textBox1.Text);


            foreach (var assembly in AllAssemblyFiles)
            {
                foreach (string CodeAssembly in AssembliesList)
                {
                    if (CodeAssembly != "System")
                    {
                        if (assembly.Contains(CodeAssembly))
                        {
                            k.RefAssemblies.Add(Assembly.LoadFile(assembly));
                        }
                    }
                }
            }

            UpdateList update = new UpdateList(UpdateUI);

            this.Invoke(update, k.RefAssemblies, CompilationClass.Classname(textBox1.Text));


            k.CompilationError += new ErrorEventHandler(k_CompilationError);
            k.CompileCSharp(textBox1.Text, "Sample.exe");
            //button1.Enabled = true;
        }
        private void Compare_Click(object sender, EventArgs e)
        {
            //Time Complexity//SpaceComplexity
            Stopwatch stopwatch = Stopwatch.StartNew(); //creates and start the instance of Stopwatch


            Process proc = Process.GetCurrentProcess();

            k.CompileCSharp(t1, "Sample.exe");
            long m1 = proc.PrivateMemorySize64;


            stopwatch.Stop();

            long s1 = stopwatch.ElapsedMilliseconds;

            Stopwatch stopwatch2 = Stopwatch.StartNew(); //creates and start the instance of Stopwatch

            Process proc2 = Process.GetCurrentProcess();

            k.CompileCSharp(t2, "Sample.exe");
            long m2 = proc2.PrivateMemorySize64;

            stopwatch2.Stop();

            long s2 = stopwatch2.ElapsedMilliseconds;



            if (s1 > s2 && c1 > c2)
            {
                MessageBox.Show("program2 is better than program1");
            }

            else
            {
                MessageBox.Show("program1 is better than program2");
            }
        }