Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            int num = Convert.ToInt32(txbNum2.Text);
            int rep = Convert.ToInt32(txtRep2.Text);

            var db = new model.OilDataManageEntities();
            this.button2.Text = "Working";
            this.button2.Enabled = false;
            ThreadStart start2 = () =>
            {
               
                double[] r = new double[rep];
                for (int k = 0; k < rep; k++)
                {
                  
                    DateTime dt = DateTime.Now;
                    var aa = db.OilData.Take(num).ToArray();
                    
                    r[k] = (DateTime.Now - dt).TotalMilliseconds;

                }
                db.Dispose();
                for (int k = 0; k < rep; k++)
                {
                    this.richTextBox2.AppendText(string.Format("读取 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1));
                }
                this.button2.Text = "Run";
                this.button2.Enabled = true;
                this.richTextBox2.AppendText("\n");
            };
            this.Invoke(start2);
        }
Exemple #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            int num = Convert.ToInt32(txtNum3.Text);
            int rep = Convert.ToInt32(txtRep3.Text);

            //先搞一条原油数据

            this.button3.Text    = "Working";
            this.button3.Enabled = false;



            ThreadStart start2 = () =>
            {
                var      db = new model.OilDataManageEntities();
                double[] r  = new double[rep];
                for (int k = 0; k < rep; k++)
                {
                    var oil = new model.OilInfo()
                    {
                        crudeIndex = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
                        crudeName  = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
                    };
                    db.OilInfo.AddObject(oil);
                    db.SaveChanges();

                    DateTime dt = DateTime.Now;
                    for (int i = 0; i < num; i++)
                    {
                        var item = new model.OilData()
                        {
                            calData       = i.ToString(),
                            labData       = i.ToString(),
                            oilInfoID     = oil.ID,
                            oilTableColID = i,
                            oilTableRowID = i
                        };
                        db.OilData.AddObject(item);
                    }
                    db.SaveChanges();
                    r[k] = (DateTime.Now - dt).TotalMilliseconds;
                }

                for (int k = 0; k < rep; k++)
                {
                    this.richTextBox3.AppendText(string.Format("插入 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1));
                }
                this.button3.Text    = "Run";
                this.button3.Enabled = true;
                this.richTextBox3.AppendText("\n");
                db.Dispose();
            };

            this.Invoke(start2);
        }