Esempio n. 1
0
        private void GenerateAuteurs()
        {
            var random = new Random();

            var dal = new AuteurEntityDal();

            // on fabrique 100 livres au max
            for (int i = 0; i < random.Next(10, 20); i++)
            {
                Random.Person p = random.NextPerson(Random.AllowedLanguage.FRENCH);

                dal.Add(p.FirstName, p.LastName);
            }
        }
Esempio n. 2
0
        static void GenereStockLivre()
        {
            var random = new Random();

            // on fabrique 100 livres au max
            for (int i = 0; i < random.Next(20, 100); i++)
            {
                Random.Person p     = random.NextPerson(Random.AllowedLanguage.FRENCH);
                string        titre = random.NextLoremIpsum(random.Next(2));

                var livre = new Livre(titre, p.FirstName, p.LastName)
                {
                    PrixUnitaireHt = random.Next(1, 200) + random.NextDouble(),
                    Quantite       = random.Next(20)
                };

                stock.Add(livre);
            }
        }
Esempio n. 3
0
        // GET: Comparer
        public ActionResult Index()
        {
            var random = new Random();

            var model = new ComparerViewModel
            {
                NbIteration = NB_ITERATION,
                Debut       = DateTime.Now
            };

            List <Auteur> auteurs;
            var           indexEntity = new List <int>();
            var           indexAdo    = new List <int>();

            DateTime start;

            #region test EntityDal

            using (var dal = new AuteurEntityDal())
            {
                // ajout
                start = DateTime.Now;
                for (int i = 0; i < NB_ITERATION; i++)
                {
                    var p = random.NextPerson(Random.AllowedLanguage.FRENCH);
                    indexEntity.Add(dal.Add(p.FirstName, p.LastName));
                }
                model.EntityDalInsert = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;

                // liste
                start   = DateTime.Now;
                auteurs = dal.GetAll();
                model.EntityDalListe = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;

                // parcours
                start = DateTime.Now;
                foreach (int i in indexEntity)
                {
                    Auteur auteur = dal.Read(i);
                }
                model.EntityDalParcours = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;

                // modification
                start = DateTime.Now;
                foreach (int i in indexEntity)
                {
                    var p = random.NextPerson(Random.AllowedLanguage.FRENCH);
                    dal.Update(i, p.FirstName, p.LastName);
                }
                model.EntityDalChange = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;

                // supprime
                start = DateTime.Now;
                foreach (int i in indexEntity)
                {
                    dal.Delete(i);
                }
                model.EntityDalSupprime = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;
            }
            #endregion

            #region AdoDal
            using (var dal = new AuteurAdoDal())
            {
                // ajout
                start = DateTime.Now;
                for (int i = 0; i < NB_ITERATION; i++)
                {
                    var p = random.NextPerson(Random.AllowedLanguage.FRENCH);
                    indexAdo.Add(dal.Add(p.FirstName, p.LastName));
                }
                model.AdoDalInsert = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;

                // liste
                start             = DateTime.Now;
                auteurs           = dal.GetAll();
                model.AdoDalListe = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;

                // parcours
                start = DateTime.Now;
                foreach (int i in indexAdo)
                {
                    Auteur auteur = dal.Read(i);
                }
                model.AdoDalParcours = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;

                // modification
                start = DateTime.Now;
                foreach (int i in indexAdo)
                {
                    var p = random.NextPerson(Random.AllowedLanguage.FRENCH);
                    dal.Update(i, p.FirstName, p.LastName);
                }
                model.AdoDalChange = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;

                // supprime
                start = DateTime.Now;
                foreach (int i in indexAdo)
                {
                    dal.Delete(i);
                }
                model.AdoDalSupprime = (int)(DateTime.Now.Subtract(start)).TotalMilliseconds;
            }
            #endregion

            model.Fin = DateTime.Now;

            ViewBag.Title = "Comparatif Entity vs ADO";

            return(View(model));
        }