internal static void Run() { var f = new Form() { Width = 400, Height = 300 }; var b = new Button() { Text = "Run", Dock = DockStyle.Fill, Font = new Font("Consolas", 18) }; f.Controls.Add(b); b.Click += async delegate { b.Text = "... Running ... "; await Task.WhenAll(WithSyncCtx(), WithoutSyncCtx()); // warm-up var sw = new Stopwatch(); sw.Restart(); await WithSyncCtx(); var withTime = sw.Elapsed; sw.Restart(); await WithoutSyncCtx(); var withoutTime = sw.Elapsed; b.Text = string.Format("With : {0}\nWithout : {1}\n\nDiff : {2:F2}x", withTime, withoutTime, withTime.TotalSeconds / withoutTime.TotalSeconds); }; f.ShowDialog(); }
static void Main() { var context = new SoftUniEntities(); // Established connection with the base //var count = context.Employees.Count(); //Console.WriteLine(count); //for (int image = 0; image < 1000; image++) //{ // context.Images.Add(new Image() // { // ImageBase64 = new string('-', 10) + image // }); // Console.WriteLine(image); //} //context.SaveChanges(); var sw = new Stopwatch(); sw.Start(); EfExtensionsDelete(context); Console.WriteLine("Standart: {0}", sw.Elapsed); sw.Restart(); NativeDelete(context); Console.WriteLine("Native: {0}", sw.Elapsed); sw.Restart(); EfStandartDelete(context); Console.WriteLine("Extensions: {0}", sw.Elapsed); }
static void Main() { Stopwatch watch = new Stopwatch(); // SQRT Console.WriteLine("SQRT:"); watch.Restart(); Sqrt.FloatSqrt(1f, 10000000f, 1f); watch.Stop(); Console.WriteLine("Float: " + watch.ElapsedMilliseconds); watch.Restart(); Sqrt.DoubleSqrt(1d, 10000000d, 1d); watch.Stop(); Console.WriteLine("Double: " + watch.ElapsedMilliseconds); watch.Restart(); Sqrt.DecimalSqrt(1m, 10000000m, 1m); watch.Stop(); Console.WriteLine("Decimal: " + watch.ElapsedMilliseconds); // Sinus Console.WriteLine("Sinus:"); watch.Restart(); Sinus.FloatSinus(1f, 10000000f, 1f); watch.Stop(); Console.WriteLine("Float: " + watch.ElapsedMilliseconds); watch.Restart(); Sinus.DoubleSinus(1d, 10000000d, 1d); watch.Stop(); Console.WriteLine("Double: " + watch.ElapsedMilliseconds); watch.Restart(); Sinus.DecimalSinus(1m, 10000000m, 1m); watch.Stop(); Console.WriteLine("Decimal: " + watch.ElapsedMilliseconds); // Logarithm Console.WriteLine("Logarithm:"); watch.Restart(); Logarithm.FloatLogarithm(1f, 10000000f, 1f); watch.Stop(); Console.WriteLine("Float: " + watch.ElapsedMilliseconds); watch.Restart(); Logarithm.DoubleLogarithm(1d, 10000000d, 1d); watch.Stop(); Console.WriteLine("Double: " + watch.ElapsedMilliseconds); watch.Restart(); Logarithm.DecimalLogarithm(1m, 10000000m, 1m); watch.Stop(); Console.WriteLine("Decimal: " + watch.ElapsedMilliseconds); }
static void Main() { TelerikAcademyEntities db = new TelerikAcademyEntities(); Stopwatch sw = new Stopwatch(); using (db) { sw.Start(); IEnumerable query = db.Employees.ToList() .Select(x => x.Address).ToList() .Select(t => t.Town).ToList() .Where(t => t.Name == "Sofia"); sw.Stop(); Console.WriteLine("Slow: {0}", sw.Elapsed); // made 644 queries sw.Restart(); IEnumerable querySmart = db.Employees .Select(x => x.Address) .Select(t => t.Town) .Where(t => t.Name == "Sofia").ToList(); sw.Stop(); Console.WriteLine("Fast: {0}", sw.Elapsed); // made 2 queries } }
static void Main(string[] args) { int[] oPos = new int[4];//0to1 - position, 2-3 - other status string[,] screen = new string[25, 55]; int[,] projectiles = new int[25, 55]; int difficulty = 420; //fills screen with space for (int i = 0; i < 25; i++) { for (int j = 0; j < 55; j++) { screen[i, j] = " "; } } for (int i = 0; i < 25; i++) { for (int j = 0; j < 55; j++) { projectiles[i, j] = 0; } } oPos[0] = 24;//i oPos[1] = 22;//j Stopwatch highScoreSw = new Stopwatch(); Stopwatch diffSw = new Stopwatch(); diffSw.Start(); highScoreSw.Start(); while (true) { if (diffSw.Elapsed.Seconds.CompareTo(5) == 1 && difficulty != 20 && diffSw.Elapsed.Seconds < 35) { difficulty -= 50; diffSw.Restart(); } Console.Clear(); GetInput(oPos); ProjMovementAndCreation(projectiles, difficulty); DrawScreen(screen, projectiles, oPos, highScoreSw); CollisionDetection(projectiles, oPos, ref difficulty); Thread.Sleep(100); } }
// Note: I have referenced the AdsEntities from the previous project // instead of creating another one in this project. static void Main() { /* * Using Entity Framework select all ads from the database, * then invoke ToList(), then filter the categories whose status is Published; * then select the ad title, category and town, then invoke ToList() * again and finally order the ads by publish date. * Rewrite the same query in a more optimized way and compare the performance. */ var context = new AdsEntities(); Stopwatch sw = new Stopwatch(); sw.Start(); for (int count = 0; count < 10; count++) { var ads = context.Ads .Select(a => a) .ToList() .Where(a => a.AdStatus != null && a.AdStatus.Status == "Published") .Select(a => new { Title = a.Title, Category = a.Category != null ? a.Category.Name : "(null)", Town = a.Town != null ? a.Town.Name : "(null)", PublishDate = a.Date }) .ToList() .OrderBy(a => a.PublishDate); } // Unoptimised: 5 seconds Console.WriteLine("Unoptimised: {0}", sw.Elapsed); sw.Restart(); for (int count = 0; count < 10; count++) { var ads = context.Ads .Where(a => a.AdStatus != null && a.AdStatus.Status == "Published") .Select(a => new { Title = a.Title, Category = a.Category != null ? a.Category.Name : "(null)", Town = a.Town != null ? a.Town.Name : "(null)", PublishDate = a.Date }) .OrderBy(a => a.PublishDate) .ToList(); } // Optimised: 0.5 seconds Console.WriteLine("Optimised: {0}", sw.Elapsed); sw.Stop(); }
private static void IncrementOccuranceCountTrie(Stopwatch sw, TrieNode start, MatchCollection allWords) { sw.Restart(); foreach (var word in allWords) { start.AddOccuranceIfExists(start, word.ToString()); } sw.Stop(); Console.WriteLine("Adding searched words count trie for: {0}", sw.Elapsed); }
static void Main() { var context = new AdsEntities1(); var stopWatch = new Stopwatch(); stopWatch.Start(); NotOptimizedMethod(context); Console.WriteLine("Not optimized method: {0}", stopWatch.Elapsed); stopWatch.Restart(); OptimizedMethod(context); Console.WriteLine("Optimized method: {0}", stopWatch.Elapsed); }
public static void SendMessage(int seconds) { Stopwatch sw = new Stopwatch(); sw.Start(); while (true) { if (sw.ElapsedMilliseconds == seconds * 1000) { Console.WriteLine("Surprise"); sw.Restart(); } } }
public void startTimer(int t) { Stopwatch sw = new Stopwatch(); sw.Start(); while (true) { if (sw.ElapsedMilliseconds >= t * 1000) { Console.WriteLine("Boom"); sw.Restart(); } } }
internal static void Run() { var sw = new Stopwatch(); while (true) { CallContext.LogicalSetData("Foo", "Bar"); // changes from default context sw.Restart(); DoWorkAsync().Wait(); var withTime = sw.Elapsed; CallContext.FreeNamedDataSlot("Foo"); // back to default context sw.Restart(); DoWorkAsync().Wait(); var withoutTime = sw.Elapsed; Console.WriteLine("With : {0}", withTime); Console.WriteLine("Without : {0}", withoutTime); Console.WriteLine("---- {0:F2}x ----", withTime.TotalSeconds / withoutTime.TotalSeconds); Console.ReadLine(); } }
private static void AddWordsForSearchInDictionary(Stopwatch sw, List<string> words, Dictionary<string, int> wordsInDictionary) { sw.Restart(); foreach (var item in words) { string word = item.ToString(); if (!wordsInDictionary.ContainsKey(word)) { wordsInDictionary[word] = 0; } } sw.Stop(); Console.WriteLine("Time to populate dictionary: {0}\n\n", sw.Elapsed); }
static void Main() { var context = new AdsEntities(); context.Database.ExecuteSqlCommand("CHECKPOINT; DBCC DROPCLEANBUFFERS;"); var sw = new Stopwatch(); Console.WriteLine(context.Ads.Any()); sw.Start(); // Messy query var ads = context.Ads .ToList() .Where(a => a.AdStatus.Status == "Published") .Select(a => new { Title = a.Title, Category = a.Category, Town = a.Town, Date = a.Date }) .ToList() .OrderBy(a => a.Date); Console.WriteLine("Millisecond with a messy query: " + sw.ElapsedMilliseconds + "ms"); sw.Restart(); var adsImproved = context.Ads .Where(a => a.AdStatus.Status == "Published") .Select(a => new { Title = a.Title, Category = a.Category, Town = a.Town, Date = a.Date }) .OrderBy(a => a.Date) .ToList(); Console.WriteLine("Millisecond with a proper query: " + sw.ElapsedMilliseconds + "ms"); // TEST RESULTS: //+---------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+--------+---------+ //| | Run 1 | Run 2 | Run 3 | Run 4 | Run 5 | Run 6 | Run 7 | Run 8 | Run 9 | Run 10 | Average | //+---------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+--------+---------+ //| Non-optimized | 237 | 245 | 243 | 247 | 256 | 237 | 236 | 266 | 236 | 237 | 244ms | //+---------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+--------+---------+ //| Optimized | 123 | 122 | 125 | 128 | 121 | 123 | 123 | 121 | 122 | 123 | 123ms | //+---------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+--------+---------+ // Improvement - Almost 2 (1.98) times faster. }
internal static void Run() { var sw = new Stopwatch(); const int ITERS = 10000000; EmptyBody(); EmptyBodyAsync(); while (true) { sw.Restart(); for (int i = 0; i < ITERS; i++) EmptyBody(); var emptyBodyTime = sw.Elapsed; sw.Restart(); for (int i = 0; i < ITERS; i++) EmptyBodyAsync(); var emptyBodyAsyncTime = sw.Elapsed; Console.WriteLine("Sync : {0}", emptyBodyTime); Console.WriteLine("Async : {0}", emptyBodyAsyncTime); Console.WriteLine("-- {0:F1}x --", emptyBodyAsyncTime.TotalSeconds / emptyBodyTime.TotalSeconds); } }
internal static void Run() { string url = "http://www.microsoft.com"; GetContents1Async(url).Wait(); GetContents2Async(url).Wait(); var sw = new Stopwatch(); while (true) { sw.Restart(); for (int i = 0; i < ITERS; i++) GetContents1Async(url).Wait(); var cacheStringTime = sw.Elapsed; sw.Restart(); for (int i = 0; i < ITERS; i++) GetContents2Async(url).Wait(); var cacheTaskTime = sw.Elapsed; Console.WriteLine("Cache string : {0}", cacheStringTime); Console.WriteLine("Cache task : {0}", cacheTaskTime); Console.WriteLine("---- {0:F2}x ----", cacheStringTime.TotalSeconds / cacheTaskTime.TotalSeconds); Console.ReadLine(); } }
private static void IncrementOccuranceCountDictionary(Stopwatch sw, Dictionary<string, int> wordsInDictionary, MatchCollection allWords) { sw.Restart(); foreach (var word in allWords) { string wordStr = word.ToString(); if (wordsInDictionary.ContainsKey(wordStr)) { wordsInDictionary[wordStr] += 1; } } sw.Stop(); Console.WriteLine("Adding searched words count dictionary for: {0}\n", sw.Elapsed); }
// Note: I have referenced the AdsEntities from the previous project // instead of creating another one in this project. static void Main() { /* * Write a program to compare the execution speed between these two scenarios: * Select everything from the Ads table and print only the ad title. * Select the ad title from Ads table and print it. */ var context = new AdsEntities(); Stopwatch sw = new Stopwatch(); sw.Start(); for (int count = 0; count < 10; count++) { var ads = context.Ads.Select(a => a); foreach (var ad in ads) { Console.WriteLine(ad.Title); } } TimeSpan unoptimisedTime = sw.Elapsed; sw.Restart(); for (int count = 0; count < 10; count++) { var ads = context.Ads.Select(a => a.Title); foreach (var adTitle in ads) { Console.WriteLine(adTitle); } } TimeSpan optimisedTime = sw.Elapsed; sw.Stop(); /* * Unoptimised: 5.5 seconds * Optimised: 0.2 seconds */ Console.WriteLine(); Console.WriteLine("Unoptimised: {0}", unoptimisedTime); Console.WriteLine("Optimised: {0}", optimisedTime); }
static void Main() { var context = new AdsEntities(); var stopwatch = new Stopwatch(); Console.WriteLine(context.Ads.Any()); stopwatch.Start(); var allAdsNoInclude = context.Ads.ToList(); Console.WriteLine(stopwatch.ElapsedMilliseconds); //foreach (var ad in allAdsNoInclude) //{ // Console.WriteLine("Ad Title: {0}, Ad Status: {1}, Ad Category: {2}, Ad Town: {3}, Ad User: {4}", // ad.Title, ad.AdStatus.Status, (ad.Category == null ? "no category" : ad.Category.Name), (ad.Town == null ? "no town" : ad.Town.Name), ad.AspNetUser.Name); //} stopwatch.Restart(); var allAdsInclude = context.Ads .Include("Category") .Include("Town") .Include("AspNetUser") .Include("AdStatus") .ToList(); Console.WriteLine(stopwatch.ElapsedMilliseconds); //foreach (var ad in allAdsInclude) //{ // Console.WriteLine("Ad Title: {0}, Ad Status: {1}, Ad Category: {2}, Ad Town: {3}, Ad User: {4}", // ad.Title, ad.AdStatus.Status, (ad.Category == null ? "no category" : ad.Category.Name), (ad.Town == null ? "no town" : ad.Town.Name), ad.AspNetUser.Name); //} // TESTS RESULTS: //+--------------------------+-----------------+-------------------+ //| | No Include(...) | With Include(...) | //+--------------------------+-----------------+-------------------+ //| Number of SQL Statements | 29 | 1 | //+--------------------------+-----------------+-------------------+ //| Milliseconds to complete | 123 | 164 | //+--------------------------+-----------------+-------------------+ }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); long number = long.Parse(Console.ReadLine()); long[] numbersArray = new long[input.Length]; for (int i = 0; i < input.Length; i++) { numbersArray[i] = long.Parse(input[i]); } //Timer on Binary Search Stopwatch timer = new Stopwatch(); timer.Start(); int numberIndex = CheckIndexUsingBinarySearch(numbersArray, number); timer.Stop(); if (numberIndex != -1) { Console.WriteLine("Number {0} found at index {1}. Elapsed time: {2}.", number, numberIndex, timer.Elapsed); } else { Console.WriteLine("Number {0} not found.", number); } //Timer on Linear Search timer.Restart(); int numberIndex2 = CheckIndexUsingLinearSearch(numbersArray, number); timer.Stop(); if (numberIndex2 != -1) { Console.WriteLine("Number {0} found at index {1}. Elapsed time: {2}.", number, numberIndex2, timer.Elapsed); } else { Console.WriteLine("Number {0} not found.", number); } }
public static void Main() { var context = new SoftUniEntities(); var totalCount = context.Employees.Count(); var stopWatch = new Stopwatch(); stopWatch.Start(); PrintNamesWithNativeQuery(context); var res = stopWatch.Elapsed; stopWatch.Restart(); PrintNamesWithLinqQuery(context); var res2 = stopWatch.Elapsed; Console.WriteLine("Native : {0}", res); Console.WriteLine("Linq : {0}", res2); stopWatch.Stop(); }
static void Main() { // Problem 1. DAO Class Test Employee employee = EmployeeDAO.FindByKey(2); Console.WriteLine(employee.LastName); employee.LastName = "Costner"; // EmployeeDAO.Modify(employee); employee = new Employee(); employee.FirstName = "Georgi"; employee.LastName = "Georgiev"; employee.JobTitle = "Production Technician"; employee.DepartmentID = 7; employee.ManagerID = 16; employee.Salary = 2000; employee.AddressID = 166; employee.HireDate = DateTime.Now; // EmployeeDAO.Add(employee); employee = EmployeeDAO.FindByKey(4); // EmployeeDAO.Delete(employee); // Problem 3. Database Search Queries // 1. Find all employees who have projects started in the time period // 2001 - 2003 (inclusive). // Select the project's name, start date, end date and manager name. var projects = EmployeeDAO.Context.Projects .Where(p => p.StartDate.Year >= 2001 && p.StartDate.Year <= 2003) .Select(p => new { ProjectName = p.Name, StartDate = p.StartDate, EndDate = p.EndDate // There is no project manager in the database }); Console.WriteLine(); Console.WriteLine("Projects started between 2001 and 2003"); Console.WriteLine(); foreach (var project in projects) { Console.WriteLine(project.ProjectName + " " + project.StartDate + " " + project.EndDate); } // 2. Find all addresses, ordered by the number of employees // who live there (descending), then by town name (ascending). // Take only the first 10 addresses and select their address text, // town name and employee count. var addresses = EmployeeDAO.Context.Addresses .OrderByDescending(a => a.Employees.Count) .Select(a => new { AddressText = a.AddressText, TownName = a.Town.Name, EmployeeCount = a.Employees.Count }).Take(10); foreach (var address in addresses) { Console.WriteLine("{0} - {1} - {2} employees", address.AddressText, address.TownName, address.EmployeeCount); } // 3. Get an employee by id (e.g. 147). // Select only his/her first name, last name, // job title and projects (only their names). // The projects should be ordered by name (ascending). var employeesSelected = EmployeeDAO.Context.Employees .Where(e => e.EmployeeID == 147) .Select(e => new { JobTitle = e.JobTitle, Projects = e.Projects.OrderBy(p => p.Name).Select(p => p.Name) }); Console.WriteLine(); Console.WriteLine("Employee with projects"); Console.WriteLine(); foreach (var employeeSelected in employeesSelected) { Console.WriteLine(" --- " + employeeSelected.JobTitle); foreach (var projectName in employeeSelected.Projects) { Console.WriteLine(projectName); } } // 4. Find all departments with more than 5 employees. // Order them by employee count (ascending). // Select the department name, manager name and first name, // last name, hire date and job title of every employee. var departments = EmployeeDAO.Context.Departments .Where(d => d.Employees.Count > 5) .OrderBy(d => d.Employees.Count) .Select(d => new { DepartmentName = d.Name, ManagerName = EmployeeDAO.Context.Employees .Where(e => e.EmployeeID == d.ManagerID) .Select(e => e.LastName).FirstOrDefault(), Employees = d.Employees.Select(e => new { FirstName = e.FirstName, LastName = e.LastName, HireDate = e.HireDate, JobTitle = e.JobTitle }) }); Console.WriteLine(); Console.WriteLine("Departments with more than 5 employees with their employees"); Console.WriteLine(); foreach (var department in departments) { Console.WriteLine(" ------------- {0}, Manager: {1}", department.DepartmentName, department.ManagerName); foreach (var departmentEmployee in department.Employees) { Console.WriteLine(" - {0} {1} - {2} - HireDate: {3}", departmentEmployee.FirstName, departmentEmployee.LastName, departmentEmployee.JobTitle, departmentEmployee.HireDate.ToString("dd/MM/yyyy")); } Console.WriteLine(); } // Problem 4. Native SQL Query // Find all employees who have projects with start date in the year 2002. // Select only their first name. // Solve this task by using both LINQ query and native SQL query through the context. Stopwatch sw = new Stopwatch(); sw.Start(); var linqResults = EmployeeDAO.Context.Employees .Where(e => e.Projects.Any(p => p.StartDate.Year == 2002)) .Select(e => e.FirstName); Console.WriteLine(string.Join(", ", linqResults)); Console.WriteLine(); Console.WriteLine("LINQ Query time: {0}", sw.Elapsed); Console.WriteLine(); sw.Restart(); var sqlQueryResults = EmployeeDAO.Context .Database .SqlQuery<string>("select e.FirstName " + "from Employees e " + "join EmployeesProjects ep on ep.EmployeeID = e.EmployeeID " + "join Projects p on ep.ProjectID = p.ProjectID " + "where DATEPART(YEAR, p.StartDate) = 2002"); Console.WriteLine(string.Join(", ", sqlQueryResults)); Console.WriteLine(); Console.WriteLine("SQL Query time: {0}", sw.Elapsed); Console.WriteLine(); sw.Stop(); // Problem 5. Concurrent Database Changes with EF var ctx1 = new SoftUniEntities(); var ctx2 = new SoftUniEntities(); var employeeToUpdate1 = ctx1.Employees.Find(7); var employeeToUpdate2 = ctx2.Employees.Find(7); employeeToUpdate1.FirstName = "Change 1"; employeeToUpdate2.FirstName = "Change 2"; ctx1.SaveChanges(); ctx2.SaveChanges(); // Without concurrency fixed - the last change is submitted // in the other case - the first one is submitted // Problem 6. Call a Stored Procedure Console.WriteLine(); Console.WriteLine("Stored Procedure result:"); Console.WriteLine(); var result = EmployeeDAO.GetProjectsByEmployee(employeeToUpdate1); foreach (var project in result) { Console.WriteLine("{0} - {1} - {2}", project.Name, project.StartDate.ToString("dd/MM/yyyy"), project.EndDate != null ? project.EndDate.ToString() : "(NULL)"); } }
// Comparaes the speed of two parsing methods static void SpeedTest() { string openTag = "<upcase>"; string closeTag = "</upcase>"; // Generate random text with some tags string longText = GenerateRandomText(openTag, closeTag); // Check if text can be parsed Console.WriteLine(ParseText(longText, openTag, closeTag) == ParseTextRegex(longText, openTag, closeTag)); Stopwatch sw = new Stopwatch(); int repeat = 10000; // Measure method 1 sw.Restart(); for (int i = 0; i < repeat; i++) { ParseText(longText, openTag, closeTag); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); // Measure method 2 sw.Restart(); for (int i = 0; i < repeat; i++) { ParseTextRegex(longText, openTag, closeTag); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); }
static void DrawScreen(string[,] screen, int[,] projectiles, int[] oPos, Stopwatch sw) { for (int i = 0; i < 25; i++) { for (int j = 0; j < 55; j++) { if (oPos[0] == i && oPos[1] == j) { if (oPos[2] == 1) { Console.WriteLine("X"); sw.Stop(); Console.Write("Your time: {0}", sw.Elapsed); Thread.Sleep(5000); Console.Clear(); sw.Restart(); oPos[2] = 0; WipeProjectiles(projectiles); } else { Console.Write("O"); } } else if (projectiles[i, j] == 1) { Console.Write(RandomProjectile()); } else Console.Write(screen[i, j]); } if (oPos[0] == i) { } else { Console.WriteLine(); } } }
static void Main() { Stopwatch watch = new Stopwatch(); // Addition Console.WriteLine("Addition:"); watch.Restart(); Addition.AddInt(0, 10000000, 2); watch.Stop(); Console.WriteLine("Int: "+watch.ElapsedMilliseconds); watch.Restart(); Addition.AddLong(0L, 10000000L, 2L); watch.Stop(); Console.WriteLine("Long: " + watch.ElapsedMilliseconds); watch.Restart(); Addition.AddFloat(0f, 10000000f, 2f); watch.Stop(); Console.WriteLine("Float: " + watch.ElapsedMilliseconds); watch.Restart(); Addition.AddDouble(0d, 10000000d, 2d); watch.Stop(); Console.WriteLine("Double: " + watch.ElapsedMilliseconds); watch.Restart(); Addition.AddDecimal(0m, 10000000m, 2m); watch.Stop(); Console.WriteLine("Decimal: " + watch.ElapsedMilliseconds); // Substraction Console.WriteLine("Substraction:"); watch.Restart(); Substraction.SubstractInt(10000000, 0, 2); watch.Stop(); Console.WriteLine("Int: " + watch.ElapsedMilliseconds); watch.Restart(); Substraction.SubstractLong(10000000L, 0L, 2L); watch.Stop(); Console.WriteLine("Long: " + watch.ElapsedMilliseconds); watch.Restart(); Substraction.SubstractFloat(10000000f, 0f, 2f); watch.Stop(); Console.WriteLine("Float: " + watch.ElapsedMilliseconds); watch.Restart(); Substraction.SubstractDouble(10000000d, 0d, 2d); watch.Stop(); Console.WriteLine("Double: " + watch.ElapsedMilliseconds); watch.Restart(); Substraction.SubstractDecimal(10000000m, 0m, 2m); watch.Stop(); Console.WriteLine("Decimal: " + watch.ElapsedMilliseconds); // Multiplication Console.WriteLine("Multiplication:"); watch.Restart(); Mutltiplication.MultiplicateInt(1, 10000000, 2); watch.Stop(); Console.WriteLine("Int: " + watch.ElapsedMilliseconds); watch.Restart(); Mutltiplication.MultiplicateLong(1L, 10000000L, 2L); watch.Stop(); Console.WriteLine("Long: " + watch.ElapsedMilliseconds); watch.Restart(); Mutltiplication.MultiplicateFloat(1f, 10000000f, 2f); watch.Stop(); Console.WriteLine("Float: " + watch.ElapsedMilliseconds); watch.Restart(); Mutltiplication.MultiplicateDouble(1d, 10000000d, 2d); watch.Stop(); Console.WriteLine("Double: " + watch.ElapsedMilliseconds); watch.Restart(); Mutltiplication.MultiplicateDecimal(1m, 10000000m, 2m); watch.Stop(); Console.WriteLine("Decimal: " + watch.ElapsedMilliseconds); // Division Console.WriteLine("Division:"); watch.Restart(); Division.DevideInt(10000000, 0, 2); watch.Stop(); Console.WriteLine("Int: " + watch.ElapsedMilliseconds); watch.Restart(); Division.DevideLong(10000000L, 0L, 2L); watch.Stop(); Console.WriteLine("Long: " + watch.ElapsedMilliseconds); watch.Restart(); Division.DevideFloat(10000000f, 0f, 2f); watch.Stop(); Console.WriteLine("Float: " + watch.ElapsedMilliseconds); watch.Restart(); Division.DevideDouble(10000000d, 0d, 2d); watch.Stop(); Console.WriteLine("Double: " + watch.ElapsedMilliseconds); watch.Restart(); Division.DevideDecimal(10000000m, 0m, 2m); watch.Stop(); Console.WriteLine("Decimal: " + watch.ElapsedMilliseconds); }