示例#1
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("USAGE: [CommandName] [ResultsFolder] [StatisticsFile]");
                return;
            }

            var resultsFolder  = new DirectoryInfo(args[0]);
            var statisticsFile = new FileInfo(args[1]);

            var collection = OpenCollection();

            var queries = new Dictionary <string, IQuery>()
            {
                { "MailsFilteredAndSortedByDate", new MailsFilteredAndSortedByDate(collection) },
                { "SentMailCountPerEmailAccount", new SentMailCountPerEmailAccount(collection) },
                { "AllReceivedMailsForAnEmailAccount", new AllReceivedMailsForAnEmailAccount(collection) },
                { "AllMailsWithWordInSubjectOrBody", new AllMailsWithWordInSubjectOrBody(collection) },
                { "ComplexMailQuery", new ComplexMailQuery(collection) },
            };

            PerformanceTest.StartStatisticsBatch("Structured MongoDB", statisticsFile);
            foreach (var query in queries)
            {
                PerformanceTest.Run(query.Key, resultsFolder, statisticsFile, query.Value);
            }
            PerformanceTest.EndStatisticsBatch(statisticsFile);
        }
示例#2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("USAGE: [CommandName] [ResultsFolder] [StatisticsFile]");
                return;
            }

            var resultsFolder  = new DirectoryInfo(args[0]);
            var statisticsFile = new FileInfo(args[1]);

            using (var sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["EnronSQL"].ConnectionString))
            {
                sqlConnection.Open();

                var queries = new Dictionary <string, IQuery>()
                {
                    { "MailsFilteredAndSortedByDate", new MailsFilteredAndSortedByDate(sqlConnection) },
                    { "SentMailCountPerEmailAccount", new SentMailCountPerEmailAccount(sqlConnection) },
                    { "AllReceivedMailsForAnEmailAccount", new AllReceivedMailsForAnEmailAccount(sqlConnection) },
                    { "AllMailsWithWordInSubjectOrBodyWithContains", new AllMailsWithWordInSubjectOrBodyWithContains(sqlConnection) },
                    { "AllMailsWithWordInSubjectOrBodyWithLike", new AllMailsWithWordInSubjectOrBodyWithLike(sqlConnection) },
                    { "ComplexMailQuery", new ComplexMailQuery(sqlConnection) },
                };

                PerformanceTest.StartStatisticsBatch("SQL Server", statisticsFile);

                foreach (var query in queries)
                {
                    PerformanceTest.Run(query.Key, resultsFolder, statisticsFile, query.Value);
                }
                PerformanceTest.EndStatisticsBatch(statisticsFile);
            }
        }
        private static void RunSampleMapping1KTest()
        {
            var users = Config.CreateObjects <User>(1000);

            PerformanceTest.Run("Sample Mapping Test 1K objects",
                                () =>
            {
                var dtos = new List <UserDto>();

                foreach (var user in users)
                {
                    dtos.Add(new UserDto
                    {
                        Id    = user.Id,
                        About = user.About,
                        CreatedUtcDateTime = user.CreatedUtcDateTime,
                        DeleteUtcDateTime  = user.DeleteUtcDateTime,
                        FirstName          = user.FirstName,
                        IsPartner          = user.IsPartner,
                        IsWithoutAccess    = user.IsWithoutAccess,
                        LastName           = user.LastName,
                        Login    = user.Login,
                        Password = user.Password,
                        Rating   = user.Rating,
                        SurName  = user.SurName
                    });
                }

                var userDto = dtos.OrderBy(x => x.FirstName).FirstOrDefault();

                return(PtopResultName);
            },
                                () =>
            {
                var dtos = _mapper.Map <List <UserDto> >(users);

                var userDto = dtos.OrderBy(x => x.FirstName).FirstOrDefault();

                return(MapperResultName);
            });
        }
        private static void RunEFMapping1KTests()
        {
            var count = 1000;

            PerformanceTest.Run("EF Mapping Test 1000 objects",
                                () =>
            {
                using (var db = new BlogContext())
                {
                    var blogs = db.BlogPosts.Take(count).Select(x => new BlogPostDto
                    {
                        Id                    = x.Id,
                        Description           = x.Description,
                        DeleteUtcDateTime     = x.DeleteUtcDateTime,
                        RawContent            = x.RawContent,
                        SocialDescription     = x.SocialDescription,
                        LinkedPosts           = x.LinkedPosts,
                        LastUpdateUtcDateTime = x.LastUpdateUtcDateTime,
                        Content               = x.Content,
                        Title                 = x.Title,
                        CountReaders          = x.WhoHasReads.Count,
                        PublishedUtcDateTime  = x.PublishedUtcDateTime
                    }).ToList();

                    var blog = blogs.OrderBy(x => x.CountReaders).First();

                    return(PtopResultName);
                }
            },
                                () =>
            {
                using (var db = new BlogContext())
                {
                    var dtos = db.BlogPosts.Take(count).ProjectToList <BlogPostDto>();

                    var userDto = dtos.OrderBy(x => x.CountReaders).First();

                    return(MapperResultName);
                }
            });
        }
        private static void ConfigureMapping1KTests()
        {
            var users = Config.CreateObjects <User>(1000);

            PerformanceTest.Run("Configure Mapping Test 1K objects",
                                () =>
            {
                var dtos = new List <AnotherUserDto>();

                foreach (var user in users)
                {
                    dtos.Add(new AnotherUserDto
                    {
                        UserId             = user.Id,
                        FullName           = $"{user.FirstName} {user.SurName} {user.LastName}",
                        About              = user.About,
                        CreatedUtcDateTime = user.CreatedUtcDateTime,
                        DeleteUtcDateTime  = user.DeleteUtcDateTime,
                        IsPartner          = user.IsPartner,
                        IsWithoutAccess    = user.IsWithoutAccess,
                        Login              = user.Login,
                        Password           = user.Password,
                        Rating             = user.Rating
                    });
                }

                var userDto = dtos.Last();

                //Console.WriteLine(userDto.FullName);

                return(PtopResultName);
            },
                                () =>
            {
                var dtos = _mapper.Map <List <AnotherUserDto> >(users);

                var userDto = dtos.Last();
                //Console.WriteLine(userDto.FullName);
                return(MapperResultName);
            });
        }
        private static void RunEFMapping100Tests()
        {
            var count = 100;

            PerformanceTest.Run("EF Mapping Test 100 objects",
                                () =>
            {
                using (var db = new BlogContext())
                {
                    var users = db.Users.Take(count).Select(x => new AnotherUserDto
                    {
                        UserId             = x.Id,
                        FullName           = string.Concat(x.FirstName, " ", x.SurName, " ", x.LastName),
                        About              = x.About,
                        CreatedUtcDateTime = x.CreatedUtcDateTime,
                        DeleteUtcDateTime  = x.DeleteUtcDateTime,
                        IsPartner          = x.IsPartner,
                        IsWithoutAccess    = x.IsWithoutAccess,
                        Login              = x.Login,
                        Password           = x.Password,
                        Rating             = x.Rating
                    }).ToList();

                    var user = users.OrderBy(x => x.FullName).First();

                    return(PtopResultName);
                }
            },
                                () =>
            {
                using (var db = new BlogContext())
                {
                    var users = db.Users.Take(count).ProjectToList <AnotherUserDto>();

                    var user = users.OrderBy(x => x.FullName).First();

                    return(MapperResultName);
                }
            });
        }
        private static void RunSampleMapping10KTest()
        {
            var blogs = Config.CreateObjects <BlogPost>(10000);

            PerformanceTest.Run("Sample Mapping Test 10K objects",
                                () =>
            {
                var dtos = new List <BlogPostDto>();

                foreach (var blog in blogs)
                {
                    dtos.Add(new BlogPostDto
                    {
                        Id                    = blog.Id,
                        Content               = blog.Content,
                        Description           = blog.Description,
                        LastUpdateUtcDateTime = blog.LastUpdateUtcDateTime,
                        DeleteUtcDateTime     = blog.DeleteUtcDateTime,
                        LinkedPosts           = blog.LinkedPosts,
                        PublishedUtcDateTime  = blog.PublishedUtcDateTime,
                        RawContent            = blog.RawContent,
                        SocialDescription     = blog.SocialDescription,
                        Title                 = blog.Title
                    });
                }

                var blogDto = dtos.LastOrDefault();

                return(PtopResultName);
            },
                                () =>
            {
                var dtos = _mapper.Map <List <BlogPostDto> >(blogs);

                var blogDto = dtos.LastOrDefault();

                return(MapperResultName);
            });
        }
示例#8
0
文件: Program.cs 项目: fthoms/jiminy
        static void Main(string[] args)
        {
            var test = new PerformanceTest();

            test.Run();
        }