Moon.Orm性能报告

以下为有网友公司的评估测试及使用规范

大家可以下载word看看

http://pan.baidu.com/s/1hquvRuc

一、和ADO.NET进行的压力测试

说明:2000并发用户,此图为一网友公司对moon.orm的测评

二、和ADO.NET的性能对比测试

说明:同时请求10000条数据,此图为一网友公司对moon.orm的测评

三、和实体框架的对比测试

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Moon.Orm;
using EfTest.Models;
using eftest;
namespace EfTest
{
    class Program
    {
        private static readonly Stopwatch Watch = new Stopwatch();
        static void Main(string[] args)
        {
            Watch.Start();
            Database.SetInitializer(new SampleData());
            using (var db = new TestContext())
            {
                db.Database.Initialize(false);
            }
            Watch.Stop();
            //Console.WriteLine("数据库初始化完成,耗时{0}", Watch.Elapsed);
            Method01();
            StartTest();
        }

        private static void Method01()
        {
            Console.WriteLine("查询预热,防止第一次查询影响结果。");
            var db = new TestContext();
            Console.WriteLine("产品目录个数:{0}", db.Categories.Count());
            Console.WriteLine("客户个数:{0}", db.Customers.Count());
            Console.WriteLine("产品个数:{0}", db.Products.Count());
            Console.WriteLine("订单个数:{0}", db.Orders.Count());
            Console.WriteLine("订单明细个数:{0}", db.OrderDetails.Count());
            db.Dispose();
            Console.WriteLine("查询预热结束-------------------------\r\n");
        }

        private static void StartTest()
        {
            Console.WriteLine("单表查询");
            EFTest1();
            MoonTest1();
            MoonDyanimic();
            Console.WriteLine();
            
            Console.WriteLine("连接查询");
            EFTestJoin();
            MoonTestJoin();
            Console.WriteLine();
            
            
            
            Console.WriteLine("嵌套查询");
            EFTestQianTao();
            MoonTestQianTao();
            
            Console.Read();
        }
        
        
        
        private static void EFTest1()
        {
            
            Watch.Restart();
            var db = new TestContext();
            db.Configuration.AutoDetectChangesEnabled=false;
            
            var list = db.OrderDetails.Where(m=>m.DetailId>1&&m.UnitPrice>0).ToList();
            db.Dispose();
            
            Watch.Stop();
            
            Console.WriteLine("  EFTest1:"+Watch.Elapsed);
        }
        
        private static void MoonTest1()
        {
            
            Watch.Restart();
            using (Db db=Db.CreateDefaultDb()) {
                var mql2=OrderDetailsSet.SelectAll().Where(OrderDetailsSet.UnitPrice.BiggerThan(0).And(OrderDetailsSet.DetailId.BiggerThan(1)));
                var list2=db.GetEntities<OrderDetails>(mql2);
                
                
            }
            Watch.Stop();
            Console.WriteLine("MoonTest1:"+Watch.Elapsed);
        }
        
        private static void MoonDyanimic()
        {
            using (Db db=Db.CreateDefaultDb()) {
                
                var list2=db.GetDynamicList("select * from OrderDetails where DetailId>10 ","hi");
                

            }
            Watch.Restart();
            using (Db db=Db.CreateDefaultDb()) {
                
                var mql=OrderDetailsSet.SelectAll();
                
                
                var list2=db.GetDynamicList("select * from OrderDetails where DetailId>1 and UnitPrice>0 ","hi");
                

            }
            Watch.Stop();
            Console.WriteLine("MoonDyanimic:"+Watch.Elapsed);
        }
        
        
        private static void EFTestJoin()
        {
            
            Watch.Restart();
            var db = new TestContext();
            db.Configuration.AutoDetectChangesEnabled=false;
            
            var list = db.OrderDetails.Where(m=>m.DetailId>3&&m.UnitPrice>0).Select(m => new
                                                                                    {
                                                                                        m.DetailId,
                                                                                        m.UnitPrice,
                                                                                        m.Product.ProductName
                                                                                    }).ToList();
            foreach (var A in list) {
                Console.WriteLine(A.DetailId+"  "+A.UnitPrice+" "+A.ProductName);
                break;
            }
            
            db.Dispose();
            Watch.Stop();
            Console.WriteLine("  EFTestJoin:"+Watch.Elapsed);
        }
        
        private static void MoonTestJoin()
        {
            
            Watch.Restart();
            using (Db db=Db.CreateDefaultDb()) {
                var mql2=OrderDetailsSet.Select(OrderDetailsSet.DetailId,OrderDetailsSet.UnitPrice);
                var mql=ProductsSet.Select(ProductsSet.ProductName);
                
                var join=mql.LeftJoin(mql2).
                    ON(OrderDetailsSet.ProductId.Equal(ProductsSet.ProductId)).
                    Where(OrderDetailsSet.UnitPrice.BiggerThan(0).And(OrderDetailsSet.DetailId.BiggerThan(3)));
                
                var list2=db.GetDictionaryList(join);
                foreach (var A in list2) {
                    Console.WriteLine(A["DetailId"]+"  "+A["UnitPrice"]+" "+A["ProductName"]);
                    break;
                }

            }
            Watch.Stop();
            Console.WriteLine("MoonTestJoin:"+Watch.Elapsed);
        }
        
        private static void MoonTestQianTao()
        {
            
            Watch.Restart();
            using (Db db=Db.CreateDefaultDb()) {
                
                var mql=ProductsSet.SelectAll().Where(
                    ProductsSet.CategoryId.In(
                        CategoriesSet.Select(CategoriesSet.CategoryId).Where(CategoriesSet.CategoryName.Equal("分类00"))
                    )
                );
                var sql=mql.ToDebugSQL();
                var list=db.GetEntities<Products>(mql);
                

            }
            Watch.Stop();
            Console.WriteLine("MoonTestQianTao:"+Watch.Elapsed);
        }
        
        private static void EFTestQianTao()
        {
            
            Watch.Restart();
            var db = new TestContext();
            db.Configuration.AutoDetectChangesEnabled=false;
            
            var list = db.Products.Where(m=>m.Category.CategoryName.Equals("分类00")).ToList();
            
            db.Dispose();
            Watch.Stop();
            Console.WriteLine("  EFTestQianTao:"+Watch.Elapsed);
        }
    }
}

执行文件下载地址
http://pan.baidu.com/s/1i3khc0H
先在sqlserver数据库中建一个名为:TestContext
的数据库,
您只需修改配置文件中的连接字符串
然后运行即可

 以下为网友运行截图

 

 

posted @ 2013-12-13 11:42  [秦时明月]  阅读(4846)  评论(3编辑  收藏  举报