Example #1
0
        static void Main(string[] args)
        {
            PCInfo pi = new PCInfo();

            String pcspec = pi.showSpec() + "\n--------------------\n" + pi.showDriveInfo();
            Console.WriteLine(pcspec);

            if (args.Count() == 0)
            {
                Console.WriteLine("Usage : PerfLog 'Process Name' [-I=MilliSeconds (default = 2000)] [-O=Output file name]");
                return;
            }

            ProcessMonitor pm = new ProcessMonitor();

            int intval = 2000;
            String pname = "";
            String ofile = "";

            foreach (String arg in args)
            {
                if (-1 < arg.IndexOf("-I="))
                {
                    intval = int.Parse(arg.Substring(3));
                }
                else if (-1 < arg.IndexOf("-O"))
                {
                    ofile = arg.Substring(3);
                    File.AppendAllText(ofile, pcspec + "\n");
                }
                else
                {
                    pname = arg;
                }
            }

            if (pname == "")
            {
                Console.WriteLine("Process name should be given!! PerfLog exitted...");
                return;
            }

            int cnt = 0;
            while (true)
            {
                String ppl = pm.getProcessPerfLog(args[0]);

                if (1 < ppl.Length)
                {
                    if (0 < cnt)
                    {
                        Console.WriteLine("");
                        cnt = 0;
                    }

                    String msg = "===============================================================================\n"
                               + DateTime.Now.ToLongTimeString()
                               + pm.getPCPerformance()
                               + "---------------------\n"
                               + ppl;

                    Console.WriteLine(msg);

                    if (ofile != "")
                    {
                        File.AppendAllText(ofile, msg);
                    }

                    if (intval <= 0)
                    {
                        break;
                    }
                }
                else
                {
                    if (cnt == 0)
                    {
                        Console.Write("Awaiting");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                    cnt++;
                }

                System.Threading.Thread.Sleep(intval);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            PCInfo pi = new PCInfo();

            String pcspec = pi.showSpec() + "\n--------------------\n" + pi.showDriveInfo();

            Console.WriteLine(pcspec);

            if (args.Count() == 0)
            {
                Console.WriteLine("Usage : PerfLog 'Process Name' [-I=MilliSeconds (default = 2000)] [-O=Output file name]");
                return;
            }

            ProcessMonitor pm = new ProcessMonitor();

            int    intval = 2000;
            String pname  = "";
            String ofile  = "";

            foreach (String arg in args)
            {
                if (-1 < arg.IndexOf("-I="))
                {
                    intval = int.Parse(arg.Substring(3));
                }
                else if (-1 < arg.IndexOf("-O"))
                {
                    ofile = arg.Substring(3);
                    File.AppendAllText(ofile, pcspec + "\n");
                }
                else
                {
                    pname = arg;
                }
            }

            if (pname == "")
            {
                Console.WriteLine("Process name should be given!! PerfLog exitted...");
                return;
            }

            int cnt = 0;

            while (true)
            {
                String ppl = pm.getProcessPerfLog(args[0]);


                if (1 < ppl.Length)
                {
                    if (0 < cnt)
                    {
                        Console.WriteLine("");
                        cnt = 0;
                    }

                    String msg = "===============================================================================\n"
                                 + DateTime.Now.ToLongTimeString()
                                 + pm.getPCPerformance()
                                 + "---------------------\n"
                                 + ppl;

                    Console.WriteLine(msg);


                    if (ofile != "")
                    {
                        File.AppendAllText(ofile, msg);
                    }

                    if (intval <= 0)
                    {
                        break;
                    }
                }
                else
                {
                    if (cnt == 0)
                    {
                        Console.Write("Awaiting");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                    cnt++;
                }


                System.Threading.Thread.Sleep(intval);
            }
        }