예제 #1
0
        public void generating_time_collisions()
        {
            DateTimeStamp[] all     = new DateTimeStamp[8192];
            DateTimeStamp   current = DateTimeStamp.UtcNow;

            for (int i = 0; i < all.Length; ++i)
            {
                DateTimeStamp next = new DateTimeStamp(current, DateTime.UtcNow);
                all[i] = current = next;
            }
            TimeSpan delta          = all[all.Length - 1].TimeUtc - all[0].TimeUtc;
            int      collisionCount = all.Count(d => d.Uniquifier != 0);

            Console.WriteLine($"Delta = {delta}, Collisions = {collisionCount}.");
        }
예제 #2
0
        public void generating_forced_time_collisions()
        {
            DateTimeStamp fake = DateTimeStamp.UtcNow;

            Stopwatch w = new Stopwatch();

            w.Start();

            DateTimeStamp[] all     = new DateTimeStamp[8192];
            DateTimeStamp   current = fake;

            for (int i = 0; i < all.Length; ++i)
            {
                DateTimeStamp next = new DateTimeStamp(current, fake);
                all[i] = current = next;
            }
            TimeSpan delta          = all[all.Length - 1].TimeUtc - all[0].TimeUtc;
            int      collisionCount = all.Count(d => d.Uniquifier != 0);

            Console.WriteLine($"Delta = {delta}, Collisions = {collisionCount}.");

            w.Stop();
            Console.WriteLine($"Ticks = {w.ElapsedTicks}.");
        }