static void Main(string[] args)
        {
            HTMLparserTest oT = new HTMLparserTest();

            try
            {
                // check if we need to benchmark it
                int iParseTimes = 1;

                string sCurDir = "";

                string sName = "majestic12.html";

                // parse command line for options
                if (args.Length > 0)
                {
                    string sCmdParamCurDir = "-c=";

                    string sCmdParamFile = "-f=";

                    // check for no delay sign
                    for (int i = 0; i < args.Length; i++)
                    {
                        // check if working directory is specified in command line
                        if (args[i].StartsWith(sCmdParamCurDir))
                        {
                            sCurDir = args[i].Substring(sCmdParamCurDir.Length, args[i].Length - sCmdParamCurDir.Length);
                            continue;
                        }

                        // check if working directory is specified in command line
                        if (args[i].StartsWith(sCmdParamFile))
                        {
                            sName = args[i].Substring(sCmdParamFile.Length, args[i].Length - sCmdParamFile.Length);
                            continue;
                        }

                        if (args[i].ToLower().Trim() == "nodelay")
                        {
                            oT.bReadLineDelay = false;
                        }
                        else
                        {
                            // must be benchmark number
                            try
                            {
                                iParseTimes = int.Parse(args[i]);

                                Console.WriteLine("Running benchmark parsing {0} times", iParseTimes);
                            }
                            catch
                            {
                                Console.WriteLine("Benchmark number={0} is incorrect - should be integer", args[i]);
                                return;
                            }
                        }
                    }
                }

                // during debugging current directory will be in \bin\debug, so we will fix it here
                // to be where the source code is to be able to open file without having to hard code directory
                // either into project or code
                if (sCurDir != "")
                {
                    Directory.SetCurrentDirectory(sCurDir);
                }
                else
                {
                    sCurDir = Directory.GetCurrentDirectory().ToLower();
                    int iIdx = sCurDir.IndexOf(@"bin\debug");

                    if (iIdx == -1)
                    {
                        iIdx = sCurDir.IndexOf(@"bin\release");
                    }

                    if (iIdx != -1)
                    {
                        sCurDir = sCurDir.Substring(0, iIdx);
                        Directory.SetCurrentDirectory(sCurDir);
                    }
                }
                // now parse HTML
                oT.Start(iParseTimes, sName);
            }
            catch (Exception oEx)
            {
                Console.WriteLine("Exception: " + oEx);
            }

            // execute a delay if we are running in interactive or benchmark mode
            if (oT.bReadLineDelay)
            {
                Console.WriteLine("Press ENTER to finish the program");
                Console.ReadLine();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            HTMLparserTest oT    = new HTMLparserTest();
            DateTime       Start = Debug.ExecStart;

            try
            {
                // check if we need to benchmark it
                int iParseTimes = 1;

                string sCurDir = "";

                // parse command line for options
                if (args.Length > 0)
                {
                    string sCmdParam = "-c=";

                    // check for no delay sign
                    for (int i = 0; i < args.Length; i++)
                    {
                        // check if working directory is specified in command line
                        if (args[i].StartsWith(sCmdParam))
                        {
                            sCurDir = args[i].Substring(sCmdParam.Length, args[i].Length - sCmdParam.Length);
                            continue;
                        }

                        if (args[i].ToLower().Trim() == "nodelay")
                        {
                            oT.bReadLineDelay = false;
                        }
                        else
                        {
                            // must be benchmark number
                            try
                            {
                                iParseTimes = int.Parse(args[i]);

                                ClassLogger.Log(LogLevel.Trace, String.Format("{0} Execution Time: {1}", Debug.FunctionName, Debug.GetExecTime(Start)), "");
                                // Console.WriteLine("Running benchmark parsing {0} times", iParseTimes);
                            }
                            catch (Exception Ex)
                            {
                                ClassLogger.LogException(LogLevel.Warn, String.Format("{0} threw exception {1}.", Debug.FunctionName, Ex.Message), null);
                                // Console.WriteLine("Benchmark number={0} is incorrect - should be integer", args[i]);
                                return;
                            }
                        }
                    }
                }

                // during debugging current directory will be in \bin\debug, so we will fix it here
                // to be where the source code is to be able to open file without having to hard code directory
                // either into project or code
                if (sCurDir != "")
                {
                    Directory.SetCurrentDirectory(sCurDir);
                }
                else
                {
                    sCurDir = Directory.GetCurrentDirectory().ToLower();
                    int iIdx = sCurDir.IndexOf(@"bin\debug");

                    if (iIdx == -1)
                    {
                        iIdx = sCurDir.IndexOf(@"bin\release");
                    }

                    if (iIdx != -1)
                    {
                        sCurDir = sCurDir.Substring(0, iIdx);
                        Directory.SetCurrentDirectory(sCurDir);
                    }
                }
                // now parse HTML
                oT.Start(iParseTimes);
            }
            catch (Exception oEx)
            {
                ClassLogger.LogException(LogLevel.Warn, String.Format("{0} threw exception {1}.", Debug.FunctionName, oEx.Message), null);
                //Console.WriteLine("Exception: " + oEx);
            }

            // execute a delay if we are running in interactive or benchmark mode
            //if(oT.bReadLineDelay)
            //{
            //Console.WriteLine("Press ENTER to finish the program");
            //Console.ReadLine();
            //}
        }
Exemple #3
0
        static void Main(string[] args)
        {
            HTMLparserTest oT=new HTMLparserTest();

            try
            {
                // check if we need to benchmark it
                int iParseTimes=1;

                string sCurDir="";

                string sName="majestic12.html";

                // parse command line for options
                if(args.Length>0)
                {
                    string sCmdParamCurDir="-c=";

                    string sCmdParamFile="-f=";

                    // check for no delay sign
                    for(int i=0; i<args.Length; i++)
                    {
                        // check if working directory is specified in command line
                        if(args[i].StartsWith(sCmdParamCurDir))
                        {
                            sCurDir=args[i].Substring(sCmdParamCurDir.Length,args[i].Length-sCmdParamCurDir.Length);
                            continue;
                        }

                        // check if working directory is specified in command line
                        if(args[i].StartsWith(sCmdParamFile))
                        {
                            sName=args[i].Substring(sCmdParamFile.Length,args[i].Length-sCmdParamFile.Length);
                            continue;
                        }

                        if(args[i].ToLower().Trim()=="nodelay")
                            oT.bReadLineDelay=false;
                        else
                        {
                            // must be benchmark number
                            try
                            {
                                iParseTimes=int.Parse(args[i]);

                                Console.WriteLine("Running benchmark parsing {0} times",iParseTimes);
                            }
                            catch
                            {
                                Console.WriteLine("Benchmark number={0} is incorrect - should be integer",args[i]);
                                return;
                            }

                        }
                    }

                }

                // during debugging current directory will be in \bin\debug, so we will fix it here
                // to be where the source code is to be able to open file without having to hard code directory
                // either into project or code
                if(sCurDir!="")
                {
                    Directory.SetCurrentDirectory(sCurDir);
                }
                else
                {

                    sCurDir=Directory.GetCurrentDirectory().ToLower();
                    int iIdx=sCurDir.IndexOf(@"bin\debug");

                    if(iIdx==-1)
                        iIdx=sCurDir.IndexOf(@"bin\release");

                    if(iIdx!=-1)
                    {
                        sCurDir=sCurDir.Substring(0,iIdx);
                        Directory.SetCurrentDirectory(sCurDir);
                    }
                }
                // now parse HTML
                oT.Start(iParseTimes,sName);
            }
            catch(Exception oEx)
            {
                Console.WriteLine("Exception: "+oEx);
            }

            // execute a delay if we are running in interactive or benchmark mode
            if(oT.bReadLineDelay)
            {
                Console.WriteLine("Press ENTER to finish the program");
                Console.ReadLine();
            }
        }