Example #1
0
 /**
  * Constructor taking the name and the address of the Node
  *
  * @param nodeName
  *            Symbolic name of the Node
  * @param nodeAddress
  *            Symbolic address of the Node
  */
 internal NodeID(String nodeName, NodeAddress nodeAddress)
 {
     this.time = CSTimer.CurrentTimeMillis();
     //this.mem = System.Runtime.GetRuntime().freeMemory();
     //this.mem = GC.GetTotalMemory(true);
     this.mem = Process.GetCurrentProcess().PrivateMemorySize64;
     //this.hashCode = new Object().hashCode();
     this.hashCode = new Object().GetHashCode();
     this.name     = nodeName;
     this.address  = nodeAddress;
 }
        public void run()
        {
            long x       = -1;
            int  warm_up = 1000;

            Console.WriteLine("warming up ... ");
            for (int i = 0; i < warm_up; i++)
            {
                x = (long)In.read();
            }

            Console.WriteLine("last number received = " + x);

            Console.WriteLine("1000 cycles completed ... timing now starting ...");

            var csv = new StringBuilder();

            int repeatTimes = 1000;

            while (repeatTimes > 0)
            {
                long t0 = CSTimer.CurrentTimeMillis();
                for (int i = 0; i < nLoops; i++)
                {
                    x = (long)In.read();
                }

                long t1 = CSTimer.CurrentTimeMillis();

                Console.WriteLine("last number received = " + x);
                long   microseconds = (t1 - t0) * 1000;
                long   iterations   = (microseconds / ((long)nLoops));
                string first        = " microseconds / iteration";
                Console.WriteLine(iterations + first);
                long   communication = (microseconds / ((long)(4 * nLoops)));
                string second        = " microseconds / communication";
                Console.WriteLine(communication + second);
                long   contextSwitch = (microseconds / ((long)(8 * nLoops)));
                string third         = " microseconds / context switch";
                Console.WriteLine(contextSwitch + third);
                var newLine = string.Format("{0},{1},{2},{3},{4},{5}", iterations, first, communication, second,
                                            contextSwitch, third);
                csv.AppendLine(newLine);


                repeatTimes--;
            }

            File.WriteAllText(@"d:\\networkedCommsTimeTEST.csv", csv.ToString());
            Console.WriteLine("Finished");
        }
        public void run()
        {
            //initialize internal arrays of 2-dimensional array
            int[][] n = new int[c.Length][];
            for (int i = 0; i < n.Length; i++)
            {
                n[i] = new int[nWritersPerChannel];
            }

            //setup variables
            const int      initialWait = 3000;
            int            iterations = nMessages * nChannels * nWritersPerChannel;
            long           t0 = 0, t1 = 0, microseconds = 0;
            Alternative    alt               = new Alternative(c);
            CSTimer        timer             = new CSTimer();
            int            channelFairSelect = 0;
            StressedPacket stressedPacket;
            var            csv = new StringBuilder();


            //set the timer to wait for 5 seconds to make sure that all the readers are idle in writing state
            Console.WriteLine("Waiting 3 seconds...");
            timer.after(initialWait + timer.read());
            Console.WriteLine("Waiting is over. Measuring time");


            //perform read and measure the time
            t0 = CSTimer.CurrentTimeMillis();
            for (int i = 0; i < iterations; i++)
            {
                channelFairSelect = alt.fairSelect();
                stressedPacket    = (StressedPacket)c[channelFairSelect].read();
                n[channelFairSelect][stressedPacket.writer] = stressedPacket.n;
            }

            t1           = CSTimer.CurrentTimeMillis();
            microseconds = (t1 - t0) * 1000;
            if (microseconds > 0)
            {
                Console.WriteLine("Reading time for " + iterations + " iterations: " + microseconds);
                var newLine = string.Format("{0},{1},{2},{3},{4}", nChannels, nWritersPerChannel, nMessages, iterations,
                                            microseconds);
                csv.AppendLine(newLine);
                File.AppendAllText(@"d:\\NetworkedstressedAlt_Test" + nChannels + "x" + nWritersPerChannel + ".csv",
                                   csv.ToString());
            }
        }
Example #4
0
        /**
         * @param clazz
         * @param message
         */
        public /*synchronized*/ void log(Type clazz, String message) //changed Java Class to Object
        {
            //Console.WriteLine(message);
            if (this.logger == null)
            {
                return;
            }
            DateTime date = new DateTime(CSTimer.CurrentTimeMillis());

            try
            {
                this.logger.WriteLine("(" + date.ToString() + ")-" + clazz.GetType().Name + ":");
                this.logger.WriteLine("\t\"" + message + "\"");
                this.logger.Flush();
            }
            catch (Exception e)
            {
                // Do nothing
            }
        }
        public void run()
        {
            const int seconds     = 1000;
            const int initialWait = 5;

            //commented out as it doesn't add any value - Karol Pasierb
            //Console.WriteLine("\nWait (" + initialWait +
            //                    " seconds) for all the writers to get going ...");
            //CSTimer tim = new CSTimer();
            //long timeout = tim.read() + (initialWait * seconds);
            //tim.after(timeout);
            //Console.WriteLine("OK - that should be long enough ...\n");
            int[][] n = new int[c.Length][];
            for (int i = 0; i < n.Length; i++)
            {
                n[i] = new int[nWritersPerChannel];
            }

            //commented out for performance testing - Karol Pasierb
            //for (int channel = 0; channel < c.Length; channel++)
            //{
            //    for (int i = 0; i < nWritersPerChannel; i++)
            //    {
            //        StressedPacket stressedPacket = (StressedPacket)c[channel].read();
            //        n[channel][stressedPacket.writer] = stressedPacket.n;
            //        for (int chan = 0; chan < channel; chan++) Console.Write("  ");
            //        Console.WriteLine("channel " + channel +
            //                            " writer " + stressedPacket.writer +
            //                            " read " + stressedPacket.n);
            //    }
            //}
            Alternative alt = new Alternative(c);
            int         counter = 0, tock = 0;
            long        t0 = 0, t1 = 0, microseconds = 0;

            while (true)
            {
                if (counter == 0)
                {
                    /*t1 = CSPTimeMillis.CurrentTimeMillis();
                     * microseconds = (t1 - t0);
                     * Console.WriteLine("Reading time for tock " + tock + ": " + microseconds);*/

                    Console.Write("Tock " + tock + " : ");
                    int total = 0;
                    for (int channel = 0; channel < n.Length; channel++)
                    {
                        Console.Write(n[channel][tock % nWritersPerChannel] + " ");
                        for (int i = 0; i < nWritersPerChannel; i++)
                        {
                            total += n[channel][i];
                        }
                    }

                    Console.WriteLine(": " + total);
                    tock++;
                    counter = 10000;
//                    t0 = CSPTimeMillis.CurrentTimeMillis();
                    //Debug.WriteLine("Read time at counter 10000");
                }

                counter--;

                t0 = CSTimer.CurrentTimeMillis();
                int            channelFairSelect = alt.fairSelect();
                StressedPacket stressedPacket    = (StressedPacket)c[channelFairSelect].read();
                n[channelFairSelect][stressedPacket.writer] = stressedPacket.n;
                t1           = CSTimer.CurrentTimeMillis();
                microseconds = (t1 - t0) * 1000;
                if (microseconds > 0)
                {
                    Debug.WriteLine("Reading time for tock " + tock + ": " + microseconds);
                }


                // for (int chan = 0; chan < channel; chan++) System.out.print ("  ");
                // Console.WriteLine ("channel " + channel +
                //                     " writer " + stressedPacket.writer +
                //                     " read " + stressedPacket.n);
            }
        }