static void Main(string[] args)
        {
            char input;

            do
            {
                ShowMenu();

                input = Console.ReadLine().First();
                switch (input)
                {
                case 'Q':
                    break;

                case 'T':
                    List <TestResult> testResults = new List <TestResult>();

                    Console.WriteLine("# of Test Runs:");
                    NumRuns = int.Parse(Console.ReadLine());

                    //Gather Details for Test
                    Console.WriteLine("# of Sports per Run: ");
                    NumSports = int.Parse(Console.ReadLine());

                    Console.WriteLine("# of Teams per Sport: ");
                    NumTeams = int.Parse(Console.ReadLine());

                    Console.WriteLine("# of Players per Team: ");
                    NumPlayers = int.Parse(Console.ReadLine());


                    List <SportDTO>  sports  = TestData.Generator.GenerateSports(NumSports);
                    List <TeamDTO>   teams   = new List <TeamDTO>();
                    List <PlayerDTO> players = new List <PlayerDTO>();
                    foreach (var sport in sports)
                    {
                        var newTeams = TestData.Generator.GenerateTeams(sport.Id, NumTeams);
                        teams.AddRange(newTeams);
                        foreach (var team in newTeams)
                        {
                            var newPlayers = TestData.Generator.GeneratePlayers(team.Id, NumPlayers);
                            players.AddRange(newPlayers);
                        }
                    }

                    Database.Reset();
                    Database.Load(sports, teams, players);

                    for (int i = 0; i < NumRuns; i++)
                    {
                        EntityFrameworkCore efCoreTest = new EntityFrameworkCore();
                        testResults.AddRange(RunTests(i, Framework.EntityFrameworkCore, efCoreTest));

                        ADONET adoTest = new ADONET();
                        testResults.AddRange(RunTests(i, Framework.ADONET, adoTest));

                        //ADONetReader adoReaderTest = new ADONetReader();
                        //testResults.AddRange(RunTests(i, Framework.ADONetDr, adoReaderTest));
                    }
                    ProcessResults(testResults);

                    break;
                }
            }while (input != 'Q');
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     ADONET.RunTest();
     DapperTest.RunTest();
 }
        static void Main(string[] args)
        {
            char input;

            AutoMapperConfiguration.Configure();
            do
            {
                ShowMenu();

                input = Console.ReadLine().First();
                switch (input)
                {
                case 'Q':
                    break;

                case 'C':
                    EntityFramework createEfTest = new EntityFramework();
                    createEfTest.CreateDatabase();
                    break;

                case 'T':
                    List <TestResult> testResults = new List <TestResult>();

                    Console.WriteLine("# of Test Runs:");
                    NumRuns = int.Parse(Console.ReadLine());

                    //Gather Details for Test
                    Console.WriteLine("# of Sports per Run: ");
                    NumSports = int.Parse(Console.ReadLine());

                    Console.WriteLine("# of Teams per Sport: ");
                    NumTeams = int.Parse(Console.ReadLine());

                    Console.WriteLine("# of Players per Team: ");
                    NumPlayers = int.Parse(Console.ReadLine());

                    for (int i = 0; i < NumRuns; i++)
                    {
                        EntityFramework efTest = new EntityFramework();
                        testResults.AddRange(RunInsertTest(i, Framework.EntityFramework, efTest));

                        ADONET adoTest = new ADONET();
                        testResults.AddRange(RunInsertTest(i, Framework.ADONET, adoTest));

                        //DataAccess.Dapper dapperTest = new DataAccess.Dapper();
                        //testResults.AddRange(RunTests(i, Framework.Dapper, dapperTest));
                    }

                    for (int i = 0; i < NumRuns; i++)
                    {
                        EntityFramework efTest = new EntityFramework();
                        testResults.AddRange(RunTests(i, Framework.EntityFramework, efTest));

                        ADONET adoTest = new ADONET();
                        testResults.AddRange(RunTests(i, Framework.ADONET, adoTest));

                        //DataAccess.Dapper dapperTest = new DataAccess.Dapper();
                        //testResults.AddRange(RunTests(i, Framework.Dapper, dapperTest));
                    }
                    ProcessResults(testResults);

                    break;
                }
            }while (input != 'Q');
        }
Beispiel #4
0
        /// <summary>
        /// Returns comparison for different ORMs like Entity Framework,
        /// Entity Framework Core, Dapper, NHibernate and ADO.Net
        /// </summary>
        /// <returns></returns>
        public JsonResult GetComparsionDetails()
        {
            try
            {
                Random random = new Random();

                int teamMemberID = 0, teamID = 0, projectID = 0;

                ADONET    adoDotNet = new ADONET(Constants.ConnectionString);
                DapperOrm dapperOrm = new DapperOrm(Constants.ConnectionString);
                EntityFrameworkCoreOrm efCoreOrm     = new EntityFrameworkCoreOrm(Constants.ConnectionString);
                EntityFrameworkOrm     efOrm         = new EntityFrameworkOrm(Constants.ConnectionString);
                NHibernateOrm          nHIbernateOrm = new NHibernateOrm();

                List <string[]> dataByMember  = new List <string[]>();
                List <string[]> dataByTeam    = new List <string[]>();
                List <string[]> dataByProject = new List <string[]>();

                int totalTeamMemberCountByTeamMember = 0,
                    totlaTeamMemberCountByTeam       = 0,
                    totalTeamMemberCountByProject    = 0;

                // Get test result of single team member fetch by id
                // from different ORMs for x iterations
                for (var i = 1; i <= Constants.IterationCount; i++)
                {
                    teamMemberID = random.Next(1, Constants.TotalTeamMembers);
                    string[] data = new string[6];

                    TestResult efResult = GetTestResultsByMember(efOrm, teamMemberID);

                    data[0] = i.ToString();
                    totalTeamMemberCountByTeamMember = efResult.MemberCount;
                    data[1] = efResult.Time.ToString();

                    TestResult efCoreResult = GetTestResultsByMember(efCoreOrm, teamMemberID);
                    data[2] = efCoreResult.Time.ToString();

                    TestResult dapperResult = GetTestResultsByMember(dapperOrm, teamMemberID);
                    data[3] = dapperResult.Time.ToString();

                    TestResult nHIbernateResult = GetTestResultsByMember(nHIbernateOrm, teamMemberID);
                    data[4] = nHIbernateResult.Time.ToString();

                    TestResult adoResult = GetTestResultsByMember(adoDotNet, teamMemberID);
                    data[5] = adoResult.Time.ToString();

                    dataByMember.Add(data);
                }

                // Get test results of team members fetch of a single team by team id
                // from different ORMs for x iterations
                for (var i = 1; i <= Constants.IterationCount; i++)
                {
                    teamID = random.Next(1, Constants.TotalTeams);
                    string[] data = new string[6];

                    TestResult efResult = GetTestResultsByTeam(efOrm, teamID);

                    data[0] = i.ToString();
                    totlaTeamMemberCountByTeam = efResult.MemberCount;
                    data[1] = efResult.Time.ToString();

                    TestResult efCoreResult = GetTestResultsByTeam(efCoreOrm, teamID);
                    data[2] = efCoreResult.Time.ToString();

                    TestResult dapperResult = GetTestResultsByTeam(dapperOrm, teamID);
                    data[3] = dapperResult.Time.ToString();

                    TestResult nHIbernateResult = GetTestResultsByTeam(nHIbernateOrm, teamID);
                    data[4] = nHIbernateResult.Time.ToString();

                    TestResult adoResult = GetTestResultsByTeam(adoDotNet, teamID);
                    data[5] = adoResult.Time.ToString();

                    dataByTeam.Add(data);
                }

                // Get test results of all team member fetch of all teams which are working on
                // specific project by project id for different ORMs for x iterations
                for (var i = 1; i <= Constants.IterationCount; i++)
                {
                    projectID = random.Next(1, Constants.TotalProjects);
                    string[] data = new string[6];

                    TestResult efResult = GetTestResultsByProject(efOrm, projectID);

                    data[0] = i.ToString();
                    totalTeamMemberCountByProject = efResult.MemberCount;

                    data[1] = efResult.Time.ToString();

                    TestResult efCoreResult = GetTestResultsByProject(efCoreOrm, projectID);
                    data[2] = efCoreResult.Time.ToString();

                    TestResult dapperResult = GetTestResultsByProject(dapperOrm, projectID);
                    data[3] = dapperResult.Time.ToString();

                    TestResult nhibernateResult = GetTestResultsByProject(nHIbernateOrm, projectID);
                    data[4] = nhibernateResult.Time.ToString();

                    TestResult adoResult = GetTestResultsByProject(adoDotNet, projectID);
                    data[5] = adoResult.Time.ToString();

                    dataByProject.Add(data);
                }

                var result = new
                {
                    tableByMember               = dataByMember,
                    tableByTeam                 = dataByTeam,
                    tableByProject              = dataByProject,
                    totalProjectCount           = Constants.TotalProjects,
                    totalTeamCount              = Constants.TotalTeams,
                    totalTeamMemberCount        = Constants.TotalTeamMembers,
                    totalMemberFetchedByMember  = totalTeamMemberCountByTeamMember,
                    totalMemberFetchedByTeam    = totlaTeamMemberCountByTeam,
                    totalMemberFetchedByProject = totalTeamMemberCountByProject
                };

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }