Example #1
0
        static void AnnouncementPart1(IEnumerable <Tuple <ulong, int> > stream)
        {
            Console.WriteLine("___ AnnouncementPart1 ____");
            // HERE WE RUN 3 EXPERIMENTS WITH l = 25, and m=16, m=128, m=1024.
            var epsilon = 0.001;
            //int t = (int) Math.Log2(8/(Math.Pow(epsilon, 2)));

            // EXPERIMENT 1, l = 25, m = 16, therefore t=4
            BigInteger sum   = new BigInteger(0);
            var        watch = Stopwatch.StartNew();

            foreach (Tuple <ulong, int> item in stream)
            {
                sum = HashFunctions.multiplyShift(item.Item1, 25) + sum;
            }

            watch.Stop();

            Console.WriteLine("[MultiplyShift]");
            Console.WriteLine("l = 25");
            Console.WriteLine("MultiplyShift sum:" + sum);
            Console.WriteLine("MultiplyShift elapsed:" + watch.ElapsedMilliseconds);
            Console.WriteLine();

            sum = 0;

            watch.Restart();
            foreach (Tuple <ulong, int> item in stream)
            {
                sum = HashFunctions.multiplyMod(item.Item1, 25) + sum;
            }
            watch.Stop();
            Console.WriteLine("[MultiplyMod]");
            Console.WriteLine("l = 25");
            Console.WriteLine("MultiplyMod sum:" + sum);
            Console.WriteLine("MultiplyMod elapsed:" + watch.ElapsedMilliseconds);
            Console.WriteLine();


            watch.Restart();
            double estimate = Algorithms.CountSketch(stream, 4);

            watch.Stop();
            Console.WriteLine("[CountSketch]\nl=25, m=16, t=4");
            Console.WriteLine("Estimate:" + estimate);
            Console.WriteLine("Elapsed time:" + watch.ElapsedMilliseconds);
            Console.WriteLine();

            watch.Restart();
            estimate = Algorithms.CountSketch(stream, 7);
            watch.Stop();
            Console.WriteLine("[CountSketch]\nl=25, m=128, t=7");
            Console.WriteLine("Estimate:" + estimate);
            Console.WriteLine("Elapsed time:" + watch.ElapsedMilliseconds);
            Console.WriteLine();

            watch.Restart();
            estimate = Algorithms.CountSketch(stream, 10);
            watch.Stop();
            Console.WriteLine("[CountSketch]\nl=25, m=1024, t=10");
            Console.WriteLine("Estimate:" + estimate);
            Console.WriteLine("Elapsed time:" + watch.ElapsedMilliseconds);
            Console.WriteLine();
        }