示例#1
0
 public SqlTaskItem(XmlElement el)
 {
     this.Name      = string.IsNullOrEmpty(el.GetAttribute("name")) ? el.InnerText.Split(' ').First() : el.GetAttribute("name");
     this.TaskCount = string.IsNullOrEmpty(el.GetAttribute("tasks")) ? 1 : int.Parse(el.GetAttribute("tasks"));
     this.Sleep     = TimeSpanEx.Parse(el.GetAttribute("sleep"));
     this.Sql       = el.InnerText;
 }
示例#2
0
        public TestFile(string filename)
        {
            var doc = new XmlDocument();

            doc.Load(filename);

            var root     = doc.DocumentElement;
            var children = root.SelectNodes("*");

            this.Timeout  = TimeSpanEx.Parse(root.GetAttribute("timeout"));
            this.Filename = root.GetAttribute("filename");
            this.Delete   = bool.Parse(root.GetAttribute("delete"));
            this.Output   = Path.Combine(Path.GetDirectoryName(this.Filename), Path.GetFileNameWithoutExtension(this.Filename) + ".log");

            this.Setup = new List <string>();
            this.Tasks = new List <ITestItem>();

            foreach (XmlElement el in children)
            {
                if (el.Name == "setup")
                {
                    this.Setup.Add(el.InnerText);
                }
                else
                {
                    var item = el.Name == "insert" ?
                               (ITestItem) new InsertTaskItem(el) :
                               (ITestItem) new SqlTaskItem(el);

                    this.Tasks.Add(item);
                }
            }
        }
示例#3
0
文件: Program.cs 项目: zamis/LiteDB
        static void Main(string[] args)
        {
            var filename = args.Length >= 1 ? args[0] : "";
            var duration = TimeSpanEx.Parse(args.Length >= 2 ? args[1] : "60s");

            var e = new TestExecution(filename, duration);

            e.Execute();

            Console.ReadKey();
        }
示例#4
0
        public InsertTaskItem(XmlElement el)
        {
            this.Name       = string.IsNullOrEmpty(el.GetAttribute("name")) ? "INSERT_" + el.GetAttribute("collection").ToUpper() : el.GetAttribute("name");
            this.Sleep      = string.IsNullOrEmpty(el.GetAttribute("sleep")) ? TimeSpan.FromSeconds(1) : TimeSpanEx.Parse(el.GetAttribute("sleep"));
            this.AutoId     = string.IsNullOrEmpty(el.GetAttribute("autoId")) ? BsonAutoId.ObjectId : (BsonAutoId)Enum.Parse(typeof(BsonAutoId), el.GetAttribute("autoId"), true);
            this.Collection = el.GetAttribute("collection");
            this.TaskCount  = string.IsNullOrEmpty(el.GetAttribute("tasks")) ? 1 : int.Parse(el.GetAttribute("tasks"));
            this.MinRange   = string.IsNullOrEmpty(el.GetAttribute("docs")) ? 1 : int.Parse(el.GetAttribute("docs").Split('~').First());
            this.MaxRange   = string.IsNullOrEmpty(el.GetAttribute("docs")) ? 1 : int.Parse(el.GetAttribute("docs").Split('~').Last());

            this.Fields = new List <InsertField>();

            foreach (XmlElement child in el.SelectNodes("*"))
            {
                this.Fields.Add(new InsertField(child));
            }
        }