Exemplo n.º 1
0
        // creates requests until we reach the steady state with a full cache
        public void OnePass()
        {
            int inst_requests = 0;
            int total_reqs = 0;
            int nreqs_to_steady = 0;
            Request[] requests = new Request[ServerSimulator.Params.NumRequests];
            Cache cache = new Cache(ServerSimulator.Params.FifoCache);
            int start = Environment.TickCount;
            int split = start;

            while (true)
            {
                total_reqs++;

                int i = ServerSimulator.Rand.Next(0, ServerSimulator.Params.NumRequests);
                if (requests[i] != null)
                {
                    requests[i].Retire();
                }
                else
                {
                    inst_requests++;
                }

                // make every nth request finalizable
                if (total_reqs % (1 / ServerSimulator.Params.FinalizableRate) == 0)
                {
                    requests[i] = new FinalizableRequest();
                }
                else
                {
                    requests[i] = new Request();
                }

                cache.Encache();

                int stop = Environment.TickCount;

                if ((stop - split) > 4000)
                {
                    Console.WriteLine("{0} reqs/sec", (total_reqs * 1000) / (stop - start));
                    split = stop;
                }

                if (cache.IsFull && (inst_requests == ServerSimulator.Params.NumRequests))
                {
                    if (nreqs_to_steady == 0)
                    {
                        nreqs_to_steady = total_reqs;
                        Console.WriteLine("took {0} iteration to reach steady state", nreqs_to_steady);
                    }
                    else if (total_reqs == ServerSimulator.Params.SteadyStateFactor * nreqs_to_steady)
                    {
                        break;
                    }
                }
            }

            for (int i = 0; i < requests.Length; i++)
            {
                if (requests[i] != null)
                {
                    requests[i].Retire();
                }
            }

            int fstop = Environment.TickCount;
            Console.WriteLine("{0} reqs/sec", (total_reqs * 1000) / (fstop - start));

            //cleanup
            static_data = null;
            cache.Clear();

        }
Exemplo n.º 2
0
        // creates requests until we reach the steady state with a full cache
        public void OnePass()
        {
            int inst_requests   = 0;
            int total_reqs      = 0;
            int nreqs_to_steady = 0;

            Request[] requests = new Request[ServerSimulator.Params.NumRequests];
            Cache     cache    = new Cache(ServerSimulator.Params.FifoCache);
            int       start    = Environment.TickCount;
            int       split    = start;

            while (true)
            {
                total_reqs++;

                int i = ServerSimulator.Rand.Next(0, ServerSimulator.Params.NumRequests);
                if (requests[i] != null)
                {
                    requests[i].Retire();
                }
                else
                {
                    inst_requests++;
                }

                // make every nth request finalizable
                if (total_reqs % (1 / ServerSimulator.Params.FinalizableRate) == 0)
                {
                    requests[i] = new FinalizableRequest();
                }
                else
                {
                    requests[i] = new Request();
                }

                cache.Encache();

                int stop = Environment.TickCount;

                if ((stop - split) > 4000)
                {
                    Console.WriteLine("{0} reqs/sec", (total_reqs * 1000) / (stop - start));
                    split = stop;
                }

                if (cache.IsFull && (inst_requests == ServerSimulator.Params.NumRequests))
                {
                    if (nreqs_to_steady == 0)
                    {
                        nreqs_to_steady = total_reqs;
                        Console.WriteLine("took {0} iteration to reach steady state", nreqs_to_steady);
                    }
                    else if (total_reqs == ServerSimulator.Params.SteadyStateFactor * nreqs_to_steady)
                    {
                        break;
                    }
                }
            }

            for (int i = 0; i < requests.Length; i++)
            {
                if (requests[i] != null)
                {
                    requests[i].Retire();
                }
            }

            int fstop = Environment.TickCount;

            Console.WriteLine("{0} reqs/sec", (total_reqs * 1000) / (fstop - start));

            //cleanup
            static_data = null;
            cache.Clear();
        }