Ejemplo n.º 1
0
        /// <summary>
        ///     Initializes the Historical data package
        /// </summary>
        /// <param name="filePath">The path to the file to load</param>
        /// <param name="factory">THe factory used to create instances of the loaded file</param>
        public static History Load(string filePath, Generated.Factory factory)
        {
            History retVal = null;

            acceptor.setFactory(factory);
            if (File.Exists(filePath))
            {
                // Do not rely on XmlBFileContext since it does not care about encoding.
                // File encoding is UTF-8
                XmlBStringContext ctxt;
                using (StreamReader file = new StreamReader(filePath))
                {
                    ctxt = new XmlBStringContext(file.ReadToEnd());
                    file.Close();
                }

                try
                {
                    retVal = acceptor.accept(ctxt) as History;
                }
                catch (XmlBException excp)
                {
                    Log.Error(ctxt.errorMessage());
                }
            }

            return retVal;
        }
Ejemplo n.º 2
0
        private void performTest(XmlBBaseAcceptor acceptor,
                                 String fname,
                                 int count,
                                 int inMem)
        {
            XmlBStringContext ctxt = new XmlBStringContext();
            String            b;

            long start = 0; //System.currentTimeMillis();

            if (!ctxt.readFile(fname))
            {
                System.Console.WriteLine("Could not open file : " +
                                         fname);
                return;
            }
            IXmlBBase[] el = new IXmlBBase[inMem];
            try
            {
                int ptr = 0;
                for (int i = 0; i < count; i++)
                {
                    if (i % 1000 == 0)
                    {
                        System.Console.WriteLine("" + (i) + "/" + count);
                    }
                    el[ptr] = acceptor.genericAccept(ctxt);
                    ctxt.setPtr(0);
                    ptr++;
                    if (ptr >= el.Length)
                    {
                        ptr = 0;
                    }
                }
                long stop = 0;//System.currentTimeMillis();
                System.Console.WriteLine("Done parsing.    Total time: " +
                                         (stop - start) + " millisecs   Time/instance: " +
                                         (stop - start) / count);
                // System.Console.WriteLine (el[0].toString());
                start = 0;//System.currentTimeMillis();
                for (int i = 0; i < count; i++)
                {
                    if (i % 1000 == 0)
                    {
                        System.Console.WriteLine("" + (i) + "/" + count);
                    }
                    b = el[0].ToString();
                }
                stop = 0;//System.currentTimeMillis();
                System.Console.WriteLine("Done unparsing.  Total time: " +
                                         (stop - start) + " millisecs   Time/instance: " +
                                         (stop - start) / count);
            }
            catch (Exception)
            {
                ctxt.dumpError();
            }
        }
Ejemplo n.º 3
0
        private void performTest(XmlBBaseAcceptor acceptor,
            String fname,
            int count,
            int inMem)
        {
            XmlBStringContext ctxt = new XmlBStringContext();
            String b;

            long start = 0; //System.currentTimeMillis();

            if (!ctxt.readFile(fname))
            {
                System.Console.WriteLine("Could not open file : " +
                           fname);
                return;
            }
            IXmlBBase[] el = new IXmlBBase[inMem];
            try
            {
                int ptr = 0;
                for (int i = 0; i < count; i++)
                {
                    if (i % 1000 == 0)
                        System.Console.WriteLine("" + (i) + "/" + count);
                    el[ptr] = acceptor.genericAccept(ctxt);
                    ctxt.setPtr(0);
                    ptr++;
                    if (ptr >= el.Length)
                        ptr = 0;
                }
                long stop = 0;//System.currentTimeMillis();
                System.Console.WriteLine("Done parsing.    Total time: " +
                           (stop - start) + " millisecs   Time/instance: " +
                           (stop - start) / count);
                // System.Console.WriteLine (el[0].toString());
                start = 0;//System.currentTimeMillis();
                for (int i = 0; i < count; i++)
                {
                    if (i % 1000 == 0)
                        System.Console.WriteLine("" + (i) + "/" + count);
                    b = el[0].ToString();
                }
                stop = 0;//System.currentTimeMillis();
                System.Console.WriteLine("Done unparsing.  Total time: " +
                           (stop - start) + " millisecs   Time/instance: " +
                           (stop - start) / count);
            }
            catch (Exception)
            {
                ctxt.dumpError();
            }
        }