Beispiel #1
0
        public static void TasksInitialize(int tasksCount)
        {
            tasks = new Task[tasksCount];

            for (int i = 0; i < tasks.Length; i++)
            {
                var choice = random.Next(100);

                /* 1% is remove */
                if (choice == 0)
                {
                    tasks[i] = new Task(() => examSystem.Remove(random.Next(), random.Next()));
                }
                /* 90% is contains */
                else if (choice > 10)
                {
                    tasks[i] = new Task(() => examSystem.Contains(random.Next(), random.Next()));
                }
                /* 9% is add */
                else
                {
                    tasks[i] = new Task(() => examSystem.Add(random.Next(), random.Next()));
                }
            }
        }
Beispiel #2
0
 static async Task AddStudents([NotNull] IExamSystem system, StudentDataRange range) => await Task.Run(() =>
 {
     for (long studentId = range.FromStudentId; studentId < range.ToStudentId; studentId += 1)
     {
         for (long courseId = range.FromCourseId; courseId < range.ToCourseId; courseId += 1)
         {
             system.Add(studentId, courseId);
         }
     }
 });
Beispiel #3
0
        private void MakeRequests(object parameter)
        {
            if (parameter as IExamSystem == null)
            {
                throw new ArgumentException("Invalid argument\n");
            }

            IExamSystem examSystem = (IExamSystem)parameter;

            for (int i = 0; i < 1024; i++)
            {
                int studentID = Math.Abs(Guid.NewGuid().GetHashCode());
                int courseID  = Math.Abs(Guid.NewGuid().GetHashCode());

                examSystem.Add(studentID, courseID);
                Assert.IsTrue(examSystem.Contains(studentID, courseID));

                examSystem.Remove(studentID, courseID);
                Assert.IsFalse(examSystem.Contains(studentID, courseID));
            }
        }
Beispiel #4
0
        static void WorkIteration(IExamSystem system, int numberOfMoves, int numberOfStudents, int numberOfCourses)
        {
            int    numberOfCotainsMoves = Convert.ToInt32(0.9 * numberOfMoves);
            int    numberOfAdditions    = Convert.ToInt32(0.09 * numberOfMoves);
            int    numberOfDeletions    = Convert.ToInt32(0.01 * numberOfMoves);
            Random random = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < numberOfAdditions; i++)
            {
                system.Add(random.Next(numberOfMoves), random.Next(numberOfCourses));
            }

            for (int i = 0; i < numberOfCotainsMoves; i++)
            {
                system.Contains(random.Next(numberOfMoves), random.Next(numberOfCourses));
            }

            for (int i = 0; i < numberOfDeletions; i++)
            {
                system.Remove(random.Next(numberOfMoves), random.Next(numberOfCourses));
            }
        }