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.Collections.Specialized;
- using System.Diagnostics;
- namespace BitVector
- {
- class Program
- {
- static void Main(string[] args)
- {
- BitVector32[] data = new BitVector32[32];
- var rand = new Random();
- //populate with random data;
- for (int y = 0; y < 32; y++)
- for (int x = 0; x < 32; x++)
- data[y][1 << x] = rand.Next(2) == 0;
- //benchmark
- while (true)
- {
- int iterations = 10000;
- int count = 0;
- var sw = new Stopwatch();
- sw.Start();
- for (int i = 0; i < iterations; i++)
- for (int y = 0; y < 32; y++)
- for (int x = 0; x < 32; x++)
- if (data[y][1 << x]) count++;
- sw.Stop();
- iterations *= 32 * 32;
- Console.WriteLine("Count: " + count.ToString("N0"));
- Console.WriteLine("Iterations: " + iterations.ToString("N0"));
- Console.WriteLine("Time: " + sw.ElapsedMilliseconds + "ms");
- Console.WriteLine("");
- Console.WriteLine((iterations / sw.ElapsedMilliseconds).ToString("N0") + " its/ms");
- Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement