Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Diagnostics;
- using System.Threading.Tasks;
- namespace simple_performance_test
- {
- class Program
- {
- static void Main(string[] args)
- {
- Stopwatch clock = new Stopwatch();
- while (true)
- {
- Console.WriteLine("");
- Console.WriteLine("Starting Test");
- clock.Restart();
- int sum = 0;
- //for (; sum < 1000000000; sum++) ;
- int work = 1000000000 / Environment.ProcessorCount;
- Parallel.For(0, Environment.ProcessorCount, (x) =>
- {
- int i = 0;
- for (; i < work; i++) ;
- sum += i;
- }
- );
- clock.Stop();
- Console.WriteLine("Took " + clock.ElapsedMilliseconds + " to iterate to " + sum);
- Console.ReadKey();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement